Reputation: 8467
I have just started to learn "Ruby" (like 2 mins before) , searched on google for tutorial
I was trying the puts
command, where I accidently wrote
irb(main):005:0> puts "nil:
irb(main):006:0" puts :
irb(main):007:0" puts "nil:
irb(main):008:0* puts "nil:
irb(main):009:0" puts "nil:
irb(main):010:0*
I noticed the change in prompt >
to "
and then *
, I really dont know what it is, could somebody explain what just happened ?
Thank you :)
By the way, if its important, I have downloaded this ruby installer
Upvotes: 1
Views: 1510
Reputation: 689
Hold control and tap C. That will clear you out. It's waiting for more input. You need to use the command as
puts "nil:"
puts "string here"
puts variable_here
Upvotes: 0
Reputation:
i wonder why wont you close your string?
should be:
puts "nil:"
changing from >
to "
means it is waiting for more input
changing from "
to *
means a beginning of a statement - in line 3 you closed you string and used nil
Upvotes: 3
Reputation: 12503
IRB is waiting for you to finish the string, like @peterpan said, IRB is able to handle multiple lines.
The *
you are seeing is because when you write the last puts "nil:
you are effectively closing the first string, and IRB is seeing now the beginning of a hash nil:
, so its expecting a value of the key nil
.
Upvotes: 2
Reputation: 3607
IRB is expecting the end of a string. You haven't closed your string on the first, so the prompt shows this with the ". Strings can span multiple lines in the irb prompt.
Upvotes: 1