I can't continue past the Math training segment due to syntax error


#1

What is the proper syntax ? I've used 1 + 1 is 2, also tried 1 + 1 => 2.


#2

You will have to assign a variable like
my_own= 2**3 * 5 / 3 + 1 ;


#3

@leonhard.wettengmx.n why is that? please explain!


#4

If you're trying to use the words "is" or the symbol "=>" that's why you're getting an error.

Ruby will do the math for you, you are not responsible for providing the answer. In other words, you only need to type 1 + 1 , not 1 + 1 is 2 or 1 + 1 => 2

If you want to capture the answer, you can assign a variable as leonhard said above.

If you're familiar with variables in algebra, it's sort of like that. In algebra, you might have a question x = 1 + 1, solve for x. You have to figure out what x is by adding 1 + 1.

But in code, Ruby will do the math for you . Ruby will add 1 + 1 and assign the answer to the variable, in this case x.

You don't have to use X, you can make up any variable name you want, but it's helpful to name variables something that represents what they stand in for like this
sum = 1 + 1

Another thing to note is that in Ruby (and many other programming languages) the = symbol isn't used for math, it's used for assignment. You use the = symbol to tell Ruby what you want the variable to mean. That's why assigning strings to variables looks the way it does.

my_name = "Kat"

my_name is the variable, and the = symbol assigns it the value of "Kat". Now, whenever I use the variable my_name Ruby will interpret it to mean the string "Kat".