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'
Sign up to request clarification or add additional context in comments.

Comments

0

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

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.