\On Wed, 2002-04-03 at 22:38, Philip Mateescu wrote: > Hi, > > I'm very new to Ruby and unfortunatelly I only had little time to look over > the pickaxe (my bad, my bad). > > Here are some of my questions I couldn't seem to get answer to: > 1. How can I make a long statement span multiple lines ? With other > languages a statement mostly ends with a terminator, but Ruby has only new > line (VB has _) If the line end in something that needs to be continued it will read the next line. For example the following is ok. a = 1 + 2 => a == 3 "Hello".sub("ll", "pp" ) => Heppo You can also use \ at the end of line a = 1 \ + 2 => a == 3 > 2. Is there an equivalent to the perldoc utility ? Or something I can use to > get quick info about classes, methods, etc ? (I could be wrong, but the > source only seems to produce ruby.exe - have I missed something ?) ri (or myri if you want a graphical version) : [bagfors / detrius]$ ; ri String#sub ------------------------------------------------------------- String#sub str.sub( pattern, replacement ) -> aString str.sub( pattern ) {| match | block } -> aString ------------------------------------------------------------------------ Returns a copy of str with the first occurrence of pattern replaced with either replacement or the value of the block. If the string form of the method is used, special variables such as $& will not be useful, as substitution into the string occurs before the pattern match starts. However, the sequences \1, \2, listed in Table 22.7 on page 376 may be used. In the block form, the current match is passed in as a parameter, and variables such as $1, $2, $`, $&, and $' will be set appropriately. The value returned by the block will be substituted for the match on each call. "hello".sub(/[aeiou]/, '*') #=> "h*llo" "hello".sub(/([aeiou])/, '<\1>') #=> "h<e>llo" "hello".sub('.') {|s| s[0].to_s + ' ' } #=> "104 ello" -- Erik BéČfors | erik / bagfors.nu Supporter of free software | GSM +46 733 279 273 fingerprint: 6666 A85B 95D3 D26B 296B 6C60 4F32 2C0B 693D 6E32