------ art_96080_19715145.1152381322981 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On 7/8/06, Yukihiro Matsumoto <matz / ruby-lang.org> wrote: > > Hi, > > In message "Re: IF test in FOR loop" > on Sun, 9 Jul 2006 01:05:23 +0900, Josselin <josselin / wanadoo.fr> > writes: > > |is it possible to test a condition (true-false) for each element in a > |loop like this : > | > |for user in @users (user.has_role? ('manager')) > |.... > |end > | > |or shoudl I write an if condition inside the loop : > | > |for user in @users > | if (user.has_role? ('manager')) > | .... > | end > |end > > for user in @users > next if user.has_role? ('manager') I like this one specifically, but try "unless" please ;) .... > end > > or > > @users.select{|user| x.has_role?('manager')}.each do |user| > ... > end > > or anything you like. > > matz. > > -- Deux choses sont infinies : l'univers et la bóŐise humaine ; en ce qui concerne l'univers, je n'en ai pas acquis la certitude absolue. - Albert Einstein ------ art_96080_19715145.1152381322981--