Stefano Crocco
8/14/2008 8:23:00 PM
On Thursday 14 August 2008, Greg Willits wrote:
> I found a suggestion that says to use return, but this generates a
> syntax error
>
> colors = ['red', 'yellow', 'green', 'blue']
>
> colors.each do |color|
> p color
> return color if color == 'yellow'
> end
>
> My actual code is a little different but I am assuming whatever
> technique solves the above would solve what I need as well.
>
> Seems like a simple syntax need, but I'm not finding a conclusive
> solution. Probably right in front of me, so sorry if it's major
> obvious...
>
> -- gw
break color if color == 'yellow'
Stefano