From: matz@... (Yukihiro Matsumoto) Date: 2000-07-06T11:48:34+09:00 Subject: [ruby-talk:03853] Re: Array.uniq! returning nil Hi, In message "[ruby-talk:03845] Re: Array.uniq! returning nil" on 00/07/05, Aleksi Niemel� writes: |But wait a second? Don't we feed if/unless with predicates like true, false, |nil? Then we must have a mistake here. *reading docs* No there's no mistake, |uniq! can be used as a "predicate" because it returns nil or the (now |modified) array which evaluates to non-nil, thus true. | |So array.uniq! *is already* a "predicate" with a side effect. "Conditions" may have side effect. Have you ever seen a code like following? while line = gets() ... end "line = gets()" is a condition for while statement, and this is an assignment, which is surely with a side effect. But I don't call these conditions with side effect as predicates. |Now, to remove '"' from my last sentence we could define predicate to match | /[\w_!]+\?/ | |Then we can mark our predicate capable to cause a side effect. When you see |array.uniq!? you know it modifies in place and acts as a predicate. Besides the "predicate" definition problem above, `foo!?' is ugly. Well, at least for my taste. matz.