There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply () below.
If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.
Join the Discussion. Help a fellow learner on their journey.
Ask or answer a question about this exercise by clicking reply () below!
Agree with a comment or answer? Like () to up-vote the contribution!
that’s the error message
(ruby):3: syntax error, unexpected tIDENTIFIER, expecting keyword_then or ‘;’ or ‘\n’
my_array.each { |x| if x % 2 === 0 push.even_array}
This is my solution and I don’t get any errors and it puts out only the even numbers. Unfortunately I can’t go on to the next exercise, the button is still greyed out.
@asimeir
For starters, I’d read the error message:
(ruby):3: syntax error, unexpected identifier, expecting keyword_then or ‘;’ or ‘\n’
It just states that Ruby thought you were going to put the keyword “then”, a semicolon, or add a new line.
@sebastian.remm984130
That prints a list. I believe that the lesson wants you to print each item on a new line.
(Also, there’s a subjectively simpler way to implement it - Ruby’s one-line if.)
I applied the list idea by byteblitz and it worked quite well. Unfortunately, my code has several lines and needs definitely improvement. I tried many ways to print each item on a new line with as less lines as possible. I have also no glue how to implement a Ruby´s one-line if.
A variation of what I’ve been seeing others have done, but not passing. I get the following message: It looks like you didn’t print anything to the console using puts!
my_array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
my_array.each { | n | puts n if n/2 == Integer }
I know now there’s a easier way, but this is what I figured out before checking the forum.