Comment

Comment by cHaOs667

It's not Ruby, it's your code... :D

class Mess

  OUTPUTS = {
    1 => ->(i) { i.odd? ? "odd" : "even" },
    2 => ->(_) { "trying" },
    3 => ->(_) { "other" }
  }.freeze

  def chaos(x)
    return puts "negative" unless x.positive?
    
    [1, 2, 3].each do |i|
      puts OUTPUTS[i]&.call(i) || "other"
    end
  end
end
parent cHaOs667 1 year ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton