The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
Parser Trivia

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Jeremy Voorhis

Posts: 212
Nickname: jvoorhis
Registered: Oct, 2005

Jeremy Voorhis is a Rubyist in northeast Ohio.
Parser Trivia Posted: Mar 8, 2006 7:22 PM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Jeremy Voorhis.
Original Post: Parser Trivia
Feed Title: JVoorhis
Feed URL: http://feeds.feedburner.com/jvoorhis
Feed Description: JVoorhis is a Rubyist in northeast Ohio. He rambles about Ruby on Rails, development practices, other frameworks such as Django, and on other days he is just full of snark.
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Jeremy Voorhis
Latest Posts From JVoorhis

Advertisement

After reading Dave Fayram’s Ruby gotcha and _why’s splat tricks, I thought I’d contribute my own Ruby syntax discovery of the day: automatic string concatenation. As you can see, it only happens when you define two strings with quotes (of any kind) consecutively in one… err… statement? Methods returning strings do not apply.


irb(main):001:0>def thing() "thing" end
irb(main):002:0> thing
=> "thing" 
irb(main):003:0> thing "string" 
ArgumentError: wrong number of arguments (1 for 0)
        from (irb):3:in `thing'
        from (irb):3
irb(main):004:0> thing() "string" 
SyntaxError: compile error
(irb):4: syntax error
thing() "string" 
         ^
        from (irb):4
irb(main):05:0> "string" thing()
SyntaxError: compile error
(irb):5: syntax error
"string" thing()
              ^
        from (irb):5
irb(main):06:0> "string " "thing" 
=> "string thing" 

Read: Parser Trivia

Topic: Fast memcached on OS X Previous Topic   Next Topic Topic: Be Like Ike

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use