0

Im new to ruby, and i want to try translate a code python to ruby.What would be a simple, and similarly on this.

print 'it has' if 'ten' in 'tentacle' else 'None'

0

2 Answers 2

10

Ruby String has method include? so it would be like:

print 'tentacle'.include?('ten') ? 'it has' : 'None'
0

If you're using rails, you can use 'in?':

puts 'ten'.in?('tentacle') ? 'it has' : 'None'

Not the answer you're looking for? Browse other questions tagged or ask your own question.