Jasmine Lognnes Jasmine Lognnes - 3 months ago 7
Ruby Question

Compact if with OR statement doesn't tricker

Inspired by this I now do

hostname = %x{hostname}

if ['staging', 'prod', 'jlpc'].include? hostname
puts "yes"
end


My Linux hostname is
jlpc
but it doesn't print out
yes
.

Why doesn't this work?

Answer

%x{hostname} => "hostname\n"

Solution puts "yes" ['staging', 'prod', 'jlpc'].include? hostname.chomp

Comments