Search code examples
rubyirb

ruby puts command


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


Solution

  • 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