15. Now You Try


Hi I am having trouble with 15. Now You Try. This is my code. It prints, on three separate lines, as follows


these are all the symbols from the array and I don’t understand why the program is still not working.

Code Below:

my_array = ["raindrops", :kettles, "whiskers", :mittens, :packages]

symbol_filter = lambda {|x| x.is_a? Symbol}

symbol = my_array.select(&symbol_filter)
puts symbol

What do i need to fix from my code?


You never set any value to packages. It just gives you the name.


Maybe this will help you visualize:

no_values = [ :a, :b, :c ]

puts no_values 
#This will result in

print no_values
[:a, :b, :c] => nil 

with_values = [a:1, b:2, c:3]

puts with_values 
#Now you'll get: 
{:a=>1, :b=>2, :c=>3}

print with_values
[{:a=>1, :b=>2, :c=>3}]


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