HELP ! Redacted in Ruby


#1

Please help me !! I don't know what I did wrong, can someone explain to me, pls ?


#2

In your each loop, "word" is just a text, word is a temporary variable that holds actual (in the loop context) element of your array.

Let's say that I have this array:

x = ["1", "2", "3"]

Now when I want to print out every element of this array I can use your code:

x.each do |word|
    print "word"
end

and it will result in:

wordwordword

because "word" is just a text.

After correcting the code:

x.each do |word|
    print word
end

we get the correct output:

123

After this correction:

print word

run your script and check how the output has changed.


#3

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