Colin Bartlett wrote: > On Sun, Jul 11, 2010 at 5:26 PM, Abder-rahman Ali < > abder.rahman.ali / gmail.com> wrote: > >> Hi, >> >> Regarding this part: >> >> sentence[open..close] = '' if close >> >> You explained what it means, but I just want to ask, what is ---> if >> close? >> > You can modify a statment with "if" or "unless". > A short *almost* (but not quite) accurate statement is that it is a > shorthand way of writing: > > if close > sentence[open..close] = '' > end > > # or > > if close then > sentence[open..close] = '' > end > > There's a fuller explanation here: > http://ruby-doc.org/docs/ProgrammingRuby/html/tut_expressions.html > at "If and Unless Modifiers" > > You can also use "while" and "until" as statement modifiers(see Loops > further down that page), but there is, as Programming Ruby says, a > "wrinkle": > "There's one wrinkle when while and until are used as statement > modifiers. > If the statement they are modifying is a begin/end block, the code in > the > block will always execute at least one time, regardless of the value of > the > boolean expression." I see it worked even when changing this part: close = sentence.index(')', open) To: close = sentence.index(')') What was the purpose of "open" as a second argument then? Thanks. -- Posted via http://www.ruby-forum.com/.