Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.ruby > #6643
| Path | csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed101.telia.com!starscream.dk.telia.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail |
|---|---|
| From | Robert Klemme <shortcutter@googlemail.com> |
| Newsgroups | comp.lang.ruby |
| Subject | Re: Ruby newbie newline question |
| Date | Tue, 09 Oct 2012 18:58:29 +0200 |
| Lines | 47 |
| Message-ID | <adj3dmFbralU1@mid.individual.net> (permalink) |
| References | <k4v5ee$o1l$1@dont-email.me> <adgs97Fqn4fU1@mid.individual.net> <k4vi9a$api$1@dont-email.me> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Trace | individual.net +7fiIqg5Mvt31OrthQIbdQFibtPk0M/25uBrBGZi5Gp23IeW0= |
| Cancel-Lock | sha1:MZXVByJkiEaJPf0d/bHCEsOaJSo= |
| User-Agent | Mozilla/5.0 (X11; Linux i686; rv:15.0) Gecko/20120912 Thunderbird/15.0.1 |
| In-Reply-To | <k4vi9a$api$1@dont-email.me> |
| Xref | csiph.com comp.lang.ruby:6643 |
Show key headers only | View raw
On 10/08/2012 11:57 PM, Gary McGath wrote: > 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 :). And that's good - definitively! > 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. Well, actually Ruby's syntax is quite flexible - maybe too flexible in some places. But it's great that you can omit brackets for methods arguments. That makes creating DSLs pretty easy. Actually some things which look like keywords are actually methods: irb(main):001:0> Class.instance_method :attr_reader => #<UnboundMethod: Class(Module)#attr_reader> irb(main):002:0> class Foo; method :attr_reader; end => #<Method: Class(Module)#attr_reader> Kind regards robert
Back to comp.lang.ruby | Previous | Next — Previous 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