Reputation: 1
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'
Upvotes: 0
Views: 689
Reputation: 3636
If you're using rails, you can use 'in?':
puts 'ten'.in?('tentacle') ? 'it has' : 'None'
Upvotes: 0
Reputation: 23556
Ruby String
has method include?
so it would be like:
print 'tentacle'.include?('ten') ? 'it has' : 'None'
Upvotes: 10