James Gray
1/7/2006 4:47:00 AM
On Jan 6, 2006, at 10:39 PM, Marcel Molina Jr. wrote:
> On Sat, Jan 07, 2006 at 01:36:30PM +0900, James Edward Gray II wrote:
>> elements = tokens.map do |token|
>> [ClassA, ClassB, ClassC].find { |kind| kind.parse?(token) }
>> end
>>
>> Except that I want the return result of parse?(), instead of the
>> class that took it.
>
> do/end doesn't bind tightly enough for the assignment to
> 'elements'. Using {}
> should work.
Sure it does:
>> numbers = (1..3).map do |n|
?> n * 2
>> end
=> [2, 4, 6]
My problem is not syntax. It's that I can't find a way to iterate to
the result of parse?().
James Edward Gray II