What's the function of quatation marks?


#1

On the very step of the chapter, there’s a mission.
In the mission, we should type true after my_boolean , and “Ruby” after my_string.
I don’t know what’s different between true without quatation marks and “Ruby” with them.
And why does the capitalization in the boolean make it a string?
Is it just like a rule or something?
Anyone please help me!


#2

ruby has data types, for example: boolean, string, integer, float and more.

It just like we have numbers, letters and words in the english language (and many other spoken language)

the quotation marks indicate a string in ruby, true is a Boolean while "true" is a string. "Ruby" is also a string. Strings are just pieces of text (okay, that is a bit simplified, but we will stick with that for now)


#3

In irb, try

true.class.name

and

“Ruby”.class.name

You will see that they are of different classes, the first being an instance of TrueClass, while the second is an instance of String. Aside from the fact that both have a common ancestor class, Object, they have nothing in common with each other.

Since they don’t have anything in common, it doesn’t make much sense to ask for their difference. You wouldn’t ask what’s the difference between a watermelon and a poem by Shakespeare, would you? :wink:

Ronald


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.