From: Jay Pangmi Date: 2008-10-16T22:31:12+09:00 Subject: Re: symbol confusions!! Rob Biedenharn wrote: > > Do you have a book like the Pickaxe?[1] That will go into great > detail on all the features that Ruby has to offer. > > Briefly, however: > > %w{} is a way to turn a list of words into an array: > %w{ one fish two fish } > => [ "one", "fish", "two", "fish" ] > > %r{} is a regular expression literal. %r{stuff.*} is like /stuff.*/ > without having to quote slashes (which is the main reason to see it > used if you're matching a file path, for example) > > %7d is probably a format specification from Kernel#sprintf or String#% > meaning a decimal value in a minimum of 7 columns: > "%7d"%42 > => " 42" > > Oh, and "Kernel#sprintf" (generally, ClassName#method) means the > instance method 'sprintf' from the class (or module) 'Kernel' (so, the > '%' method from the String class). > > -Rob > > > [1] http://www.pragprog.com/titles/ruby/programming-ruby > > > Rob Biedenharn http://agileconsultingllc.com > Rob@AgileConsultingLLC.com Thanks Rob you made my life lot easier.. no I don't have that book I just have 'Agile Web Development with Rails 2nd Edt.' so, ruby is just a small part here and hence internet has been my only source. Also I confusion about the use of slashes: %r{(\d{1,2}):(\d{1,2}):(\d{4})} whats the use of forward slash here and the '+' sign below: split(/[^0-9]+/) Also I think I've seen the use of other words with '%' like %w but I don't remember which words in particular. Thanks. -- Posted via http://www.ruby-forum.com/.