From: Adrian Arlechin Date: 2009-06-06T01:22:11+09:00 Subject: Test array and assign result to variable I have this example: class Array def find for i in 0...size value = self[i] return value if yield(value) end return nil end end x = [1, 3, 5, 7, 9] x.find {|v| v*v > 30 } It says that return 7 - the first value wich match the condition I run it in NetBeans but don't see the output I tried this: x.find {|v| if v*v > 30 puts v end } but now prints the both values that match the condition: 7, 9 So the problem is how can I see only the first match, and most important how can I extract this value to a variable to use it somewhere else. Because in general I want to test an array for a condition, and then use the results Thanks -- Posted via http://www.ruby-forum.com/.