Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Whats the difference between something in quotations and something out of quotations?

Asked by
Rhyxus 0
8 years ago

My friend who is matt1020304050 is helping me learn to script, he started off with something easy which was the print command, and going on saying that you can turn a number into a string, variables, etc, all that basic stuff. But he showed me this

Rhyxus = 5
print(Rhyxus-1)

Rhyxus = "5"
print(Rhyxus-1)

now whats the difference here since one is in quotations?

1 answer

Log in to vote
0
Answered by
Shawnyg 4330 Trusted Badge of Merit Snack Break Moderation Voter Community Moderator
8 years ago

Well, in that situation, there is no difference. I believe when you are attempting to add, subtract, multiply, or divide a string, it attempts to put it into a numerical value, which is what tonumber() does. Say if Rhyxus was equal to "5d", that would cause an error, since 'd' is not a numerical value. Quotations declare a string of text.

Example:

print("I am a string!")

An alternative way is by using the apostrophe's.

print('Still a string!')

So, you may be asking, what's the difference between an apostrophe and quotes? Well, I've got an answer. Say if I have a string of text, and I'm quoting what someone says, such as: Bill Gates said, "I like your shoes!". To put that in a variable, or print it, you'd need to use both apostrophes and quotes!:

print("Bill gates said, 'I like your shoes!'.")

That's about all you need to know about strings for now!

Ad

Answer this question