Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

"in" keyword in Ruby

Name: Anonymous 2010-03-21 16:00

Can anyone tell me what the "in" keyword is for?

I piped the users "input" (from gets) into a block, so I had
{ |in| in ..doing some shit la la la.. }
Ruby promptly threw a SyntaxError, saying that it wasn't expecting kIN.

I find plenty of documentation saying it is a reserved keyword, but I can't find a single example of what "in" does...

Name: Anonymous 2010-03-21 16:08

Ahh so it helps use the for loop to iterate over arrays, thank you kind anon, this has been bugging me all day

I am reading the Poignant guide, and they glossed over for loops in the loop section (they focus on while, and the loop methods like .each, instead of beautiful for constructs)

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List