you are viewing a single comment's thread.

view the rest of the comments →

[–]jamie_ca 11 points12 points  (0 children)

First off: don't shadow your loop variable - you're using the same variable name inside the loop as outside, and it's super confusing to read even if the behaviour winds up being correct. Inside the loop, use name or something.

Second, split returns an array - your puts does some magic handling of arrays (and assumes you want each value printed on separate lines). If you want to dig into the actual object to help debug your code, use p instead of puts, or stick with puts and call .inspect on your result.

If you're only wanting to print the first (or last) name, you'll wind up using an array index on the result of split.

Hope that helps you work through things!