Jasmine Lognnes Jasmine Lognnes - 3 months ago 8
Ruby Question

Compact if with OR statement doesn't trigger

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" if ['staging', 'prod', 'jlpc'].include? hostname.chomp`