4 ms·
A semicolon is not exactly sufficient-- it leaves the expression open, and thus unexecuted, until you close it. Try `puts 1;` vs. `puts 1;0`.
by Cushman 15y ago
A semicolon is not exactly sufficient-- it leaves the expression open, and thus unexecuted, until you close it. Try `puts 1;` vs. `puts 1;0`.
- Schwolop 15y agoThis confused the hell out of me when I came from MatLab to Ruby. I thought the semicolon was working like in MatLab to just suppress output. It wasn't... Many bugs ensued! Having now watched the video, if someone had told me that '_' in irb was equivalent to 'ans' in MatLab, I would have been very happy.
- petercooper 15y agoOhh, you're giving me ideas now. How great would it be to have a whole panoply of "[language a] for [language b] developers" videos or articles ;-) I know of a few but still..
- rue 15y agoYou're quite right! irb does indeed do that… I've been using pry, which handles it ‘correctly’.
- Cushman 15y agoIn that case, I'd say we're both right-- though it's an open question what's the "right" behavior.