2008年4月30日 星期三

all? and any?

all?  

if code block to each element of array or hash is true, then return true

ex:

rabbits.all?( &: valid? )


any?

accept block, if code block to any element of array or hash is true, then return true

ex:

[1,2, 3].any? { |i|  i>2  }

-->  ture

沒有留言: