Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.ruby > #6639
| From | Gary McGath <garym@REMOVEmcgathREMOVE.com> |
|---|---|
| Newsgroups | comp.lang.ruby |
| Subject | Re: Ruby newbie newline question |
| Date | 2012-10-08 17:57 -0400 |
| Organization | Mad Scientists' Union |
| Message-ID | <k4vi9a$api$1@dont-email.me> (permalink) |
| References | <k4v5ee$o1l$1@dont-email.me> <adgs97Fqn4fU1@mid.individual.net> |
On 10/8/12 4:44 PM, Robert Klemme wrote: > There's also ";" which can be used instead: > > $ ruby19 -ce 'if i == 1 then print "one" elsif i == 2 then print "two" end' > Syntax OK > $ ruby19 -ce 'if i == 1; print "one" elsif i == 2 then print "two" end' > Syntax OK > $ ruby19 -ce 'if i == 1 print "one" elsif i == 2 then print "two" end' > -e:1: syntax error, unexpected tIDENTIFIER, expecting keyword_then or > ';' or '\n' > if i == 1 print "one" elsif i == 2 then print "two" end > ^ > -e:1: syntax error, unexpected keyword_elsif, expecting $end > if i == 1 print "one" elsif i == 2 then print "two" end > ^ I see. Semicolon is a statement terminator, rather than being an assignment terminator as in C-family languages. Useful to know. > I'm afraid I do not have more advice here. But this was really never a > big issue for me IIRC. Just code away and let the syntax check give > your the feedback. :-) Making conservative assumptions rather than trying to pare the code to the minimum number of characters also sounds like good advice (i.e., Ruby is not Perl :). I've been using _Learning Ruby_ from O'Reilly, which is readable but not nearly as precise as I'd like. Thanks for the input. -- Gary McGath http://www.mcgath.com
Back to comp.lang.ruby | Previous | Next — Previous in thread | Next in thread | Find similar
Ruby newbie newline question Gary McGath <garym@REMOVEmcgathREMOVE.com> - 2012-10-08 14:18 -0400
Re: Ruby newbie newline question Robert Klemme <shortcutter@googlemail.com> - 2012-10-08 22:44 +0200
Re: Ruby newbie newline question Gary McGath <garym@REMOVEmcgathREMOVE.com> - 2012-10-08 17:57 -0400
Re: Ruby newbie newline question Robert Klemme <shortcutter@googlemail.com> - 2012-10-09 18:58 +0200
csiph-web