I'm confused about word usage in the instructions


#1

TL;DR Is there a guide on how the symbols = and == are verbally used?

Hi! I'm currently in lesson "Redacted!: Control flow know how."

I searched the forums to figure out where I was going wrong. I found what I was looking for, but that raised another question. "Do I really understand what I'm being told to do?"

The lesson states:

if the current word equals the word to be redacted, then print "REDACTED " with that extra space.
Otherwise (else), print word + " "

I understand it as:

if word = redact
print "REDACTED "
else
print word + " "
end

Ruby actually wanted me to type == instead of =

Is there a guide on how these symbols are said verbally?


#2

Most languages separate assignment from comparison. That is what these two operators are used for. = for assignment, == for comparison (equality).

Verbally, they are,

=     assignment operator
==    equality operator

Eg.

def multiply(x,y)
    x * y

a = 6
b = 7
c = multiply(a,b)    # 42

def pearls(str, count)
    str * count

s = pearls('*', 32)  # ********************************

a == 127    # false
a == b      # false

#3

That's not quite what I'm looking for. I'll try again.

If I were to tell someone to type "C equals A plus B" I would expect them to type
"C = A + B"

If I were to tell someone to type "A is equal to B" I would expect "A == B"

It seems that the instructions in Ruby do not agree with my view. I think if the instructions say "Assign C as A + B" then it means C = A + B

If the instructions says "A equals B" or "A is equal to B" it means A == B (am I correct?)

So back to my quote of Ruby's instructions:

  • if the current word equals the word to be redacted, then print "REDACTED " with that extra space. Otherwise (else), print word + " "*

Am I correct to think that word = redacted or should the instructions have said "is equal to?

Is there a list of phrases that tell me what I should be typing? If so, I'll study that first, and THEN continue the lessons. (less than <, greater than >, assign x to a, declare a variable called b,)

I also noticed some things like "increment" as a verb. Sometimes when I see these words or phrases pop up without previously given a definition, I'm left confused and spend more time trying to figure out what it's asking me to do rather than actually writing a code.


#4

ifis the operative word that sets up the expectation of an expression, not a statement. An assignment is a statement, a comparison is an expression. Context is a big determiner.