From: Mark Hubbart Date: 2004-07-18T14:35:11+09:00 Subject: Re: other meanings of ( and ) aka Lispy usage On Jul 17, 2004, at 8:45 PM, Nicholas Van Weerdenburg wrote: > What's the meaning of () outside of being function parameter > delimiters aka in a Lispy sense? > e.g. > (puts "command=" + (command="vi " + filename)) > > Obvious + is actual a method, so that explains the () around > "command=", but there is the () around the entire line. First, there is the expression grouping. That is what lets you say (23 + 42) * 69, or (Math.sqrt 23) + 42, or even ("this" + "that").display Then, function parameter delimeters. These are, of course, mostly optional in ruby. STDERR.puts("Yoiks!", "Stop that!") Parens can also act as statement groupings. Multiple statements can be collected into one expression, where the value of the expression -- everything inside the parens -- is given the value of the last statement. So, you can do things like this (warning! very contrived): baz = ((foo=23; bar=foo+7; bar*foo) if condition) In this, if condition is true, foo is set to 23, bar is set to 30, and the parenthetical expression returns a value of 23*30. baz will be set to 690. If condition is false, nothing else is evaluated, and baz is set to nil. I hope the last part wasn't more confusing than helpful... :/ HTH, Mark