I have downloaded and installed Rails 1.2. When I go to the command line
and go into ./script/console, I am getting something peculiar happening.
Once I am in the console, everytime I type a command and hit return to
see the results, I get a “=> nil” after every line. Can anyone explain
this? See example below:
powerbook17:~/Sites/rails/depot fernando$ ./script/console
Loading development environment.
string = “Now is the time”
=> “Now is the time”
puts string.at(2)
w
=> nil
puts string.from(8)
he time
=> nil
puts string.first
N
=> nil
puts string.starts_with?(“No”)
true
=> nil
count = Hash.new(0)
=> {}
string.each_char {|ch| count[ch] += 1}
=> nil
puts count.inspect
{" "=>3, “w”=>1, “m”=>1, “N”=>1, “o”=>1, “e”=>2, “h”=>1, “s”=>1, “t”=>2,
“i”=>2}
=> nil
puts “cat”.pluralize
cats
=> nil
Doesn’t console return whatever the previous statement equates to?
And doesn’t puts return a nil?
Seems to make sense.
I don’t normally try
instead of puts string.at(2)
try string.at(2)
you get the answer ether way.
Fernando Aleman wrote:
I have downloaded and installed Rails 1.2. When I go to the command line
and go into ./script/console, I am getting something peculiar happening.
Once I am in the console, everytime I type a command and hit return to
see the results, I get a “=> nil” after every line. Can anyone explain
this? See example below:
powerbook17:~/Sites/rails/depot fernando$ ./script/console
Loading development environment.
string = “Now is the time”
=> “Now is the time”
puts string.at(2)
w
=> nil
puts string.from(8)
he time
=> nil
puts string.first
N
=> nil
puts string.starts_with?(“No”)
true
=> nil
count = Hash.new(0)
=> {}
string.each_char {|ch| count[ch] += 1}
=> nil
puts count.inspect
{" "=>3, “w”=>1, “m”=>1, “N”=>1, “o”=>1, “e”=>2, “h”=>1, “s”=>1, “t”=>2,
“i”=>2}
=> nil
puts “cat”.pluralize
cats
=> nil
David,
Thank you for your response. You are correct. I tried the console again
without the “puts” and got the answer without the => nil. I appreciate
your assistance.
David H. wrote:
Doesn’t console return whatever the previous statement equates to?
And doesn’t puts return a nil?
Seems to make sense.
I don’t normally try
instead of puts string.at(2)
try string.at(2)
you get the answer ether way.