From: Dave Aronson Date: 2013-04-02T02:22:04+09:00 Subject: Re: Ruby Gotchas presentation slides On Sat, Mar 30, 2013 at 10:37 PM, Julian Leviston wrote: > quite a few of your "gotchas" are about how ruby is ruby. Er, well, yeah, that was kinda the point! > For example, puts 'hi' if 0 is unexpected if you're a > C programmer., but not if you're a smalltalker! Eh? I didn't bother with the "conditional after statement" stuff. That's common enough in other scripting languages, and it's just a syntax variation, not a gotcha per se. The capability may be surprising, but it's not something that you might expect to work a completely different way, or something that looks perfectly valid but isn't, due to parser quirks. > Also, your slide 20 is about a closure, not a loop. Sort of. It looks like a loop, it quacks like a loop... but the second you turn your back, it will nibble you to death with quirks like that. :-) I suppose I could make the difference, and the root cause, clearer without being TOO verbose. How's this grab you: Variables declared in /blocks passed to iterators/ (e.g., times or each) are undefined at the top of /each/ iteration! /Built-in looping constructs/ (e.g., while or for) are OK. /Iterators/ call the block repeatedly, so vars are out of scope again after each call. I've made the code skinnier (meaning the error message takes more lines), so I could extend the explanation into more lines. > If you're going to do some educating, it'd be good if you made sure > the NEW information you are propagating is as correct as possible. It's as correct as could be squeezed into the space and time available. (I was trying to keep the whole thing under an hour.) I'm considering making this into a series of screencasts, and then perhaps I can explain more. Thanks, Dave -- Dave Aronson, the T. Rex of Codosaurus LLC, secret-cleared freelance software developer taking contracts in or near NoVa or remote. See information at http://www.Codosaur.us/.