3 ms·
It's not Ruby, it's your code... :D class Mess OUTPUTS = { 1 => ->(i) { i.odd? ? "odd" : "even" }, 2 => ->(_) { "trying" }, 3 => ->(_) { "other"
by cHaOs667 1y ago
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
- cHaOs667 1y agoAnd I have no idea why HN messes up my class statement... it looks good in the text field :D
- Jtsummers 1y agoDid you start it with two spaces? That's how HN does code blocks. Two spaces added before each line. The other lines look fine because they were already indented, add two spaces before all of them and it'll look fine.