Question

In Ruby I can use

result << (yield element)

and everything works, but if I do

result.push(yield element)

I get a warning about needing parentheses for future compatibility. I can change the above to

result.push(yield(element))

and the interpreter is happy again, but I don't understand why I need parentheses in one call to yield and not the other?

Was it helpful?

Solution

You can ignore that warning. You won't get it anymore in 1.8.7 and later. The planned parser changes that were the reason for this warning, have been dismissed.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top