000 kiba 000
000 kiba 000

Reputation: 1

Equivalent python 'in' on ruby

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

Answers (2)

A Fader Darkly
A Fader Darkly

Reputation: 3636

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

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

Upvotes: 0

Hauleth
Hauleth

Reputation: 23556

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

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

Upvotes: 10

Related Questions