Search code examples
rubyiteratorputs

How puts variable in iterators code Ruby


How puts variable in iterators code Ruby EX: (1,2,3).select { |v| puts v > 2}


Solution

  • Seems syntax error, I think you want something like this

    [1,2,3].select { |v| puts v > 2 }
    

    output would be :

    false
    
    false
    
    true
    

    Take a look here