Output with quotation marks with print


My code below
print "What is your name?"
name = gets .chomp
print "Which state are you from (abbr.)" # the brackets is to remind people to type in abbrevation
state = get .chomp .upcase

produces results below:
What is your name?
Which state are you from?

Why does the last output have quotations on it? instead of just MN. Thank you.

Replace this line with your code.


Note the differences in your code. gets vs. get.

The latter does not differentiate between data types. When it receives inputs it sees it is string data, so adds the quotes (it casts it to string type).

get  => get any input and type cast as identified

gets => get string input, no casting required

It would be a good idea to avoid the use of white space in chained expressions.