If any one has a copy of "why's poignant guide to ruby", turn to page 45. I can see immediately that
i)`ruby p Dir ['*']` works and lists all files within a specified directory. However
ii)`ruby p File::methods` produces the error..."ruby: No such file or directory -- p (LoadError)"
Is ii) just a way to show the generic syntax of the command?
If any one has a copy of "why's poignant guide to ruby", turn to page 45. I can see immediately that
i)`ruby p Dir ['*']` works and lists all files within a specified directory. However
ii)`ruby p File::methods` produces the error..."ruby: No such file or directory -- p (LoadError)"
Is ii) just a way to show the generic syntax of the command?
The examples given are:
i) p Dir['idea-*.txt']
ii) p File::methods
(there are no "ruby" or backticks). You should try them on an irb shell, or
writing them on a file and then running it with "ruby file", or passing them
as a parameter to ruby, after the parameter "-e", so:
ruby -e "p Dir['idea-*.txt']"
ruby -e "p File::methods"
It's best to do that only if you understand how your command shell
interprets quotes.
Good luck.
···
I downloaded the PDF file and didn't find what you wrote on page 45, only something like it on page 35. Next time please try to find the relevant html page (it is a little upwards from <http://poignantguide.net/ruby/chapter-4.html#section4>\).
~/Desktop/ruby-1.8.4%> ri Object::new
------------------------------------------------------------ Object::new
Object::new()
···
Benjamin Stiglitz <ben@tanjero.com> wrote:
ri Object::new
------------------------------------------------------------------------
Not documented
~/Desktop/ruby-1.8.4%> ri Kernel#p
zsh: no matches found: Kernel#p
~/Desktop/ruby-1.8.4%> ri Object::new
------------------------------------------------------------ Object::new
Object::new()
------------------------------------------------------------------------
Not documented
~/Desktop/ruby-1.8.4%> ri Kernel#p
zsh: no matches found: Kernel#p
just for fun )))
--
une bévue
------------------------------------------------------------------------
For each object, directly writes obj.inspect followed by the
current output record separator to the program's standard output.
p bypasses the Ruby I/O libraries.
S = Struct.new(:name, :state)
s = S['dave', 'TX']
p s