Noob questions


Hello, i just started learning today and have few questions
1. what is the difference between: print="abc"; print "abc' or even print abc. I see they give different results sometimes, but i don't understand why
2. what is the difference between print and puts? Sometimes they work interchangeably but sometimes not.
3. why i sometimes get "nil". What is it?



1) Quotes around text means that the text is a string literal. It's a value that is just that sequence of characters, it will do nothing, it's not code, just text.
Anything else is code, so abc without the quotes will refer to that name which in turns refers to some value in memory, like 5 or "hello" or a function. If that name hasn't been defined, your interpreter will not know what to do and will stop execution, telling you what happened.
I don't know about Ruby, but in Python, single or double quotes do the same thing, you just can't close something that started with a single quote with a double quote and vice versa. It might be the same in Ruby, I do not know, google it or wait to find out by experience.
2) google it, I don't know and if I did I'd say the same. Look for official-looking documentation.
3) It's a value representing a lack of value. For example, all functions return something, but if that something is nothing, then what you'll get is nil, telling you that there's nothing there.

  1. print = "abc" creates variable print which contains the string "abc"; print "abc" will print the string "abc"; print abc will print the variable abc if it is defined, if it is not defined - you will get an error.

  2. puts has a \n newline character at the end of whatever it is printing/putting - print does not have this \n