Q:

Write a Ruby program to check whether a string starts with an other string

0

Write a Ruby program to check whether a string starts with an other string. 

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

def check_string(my_string, substr)
   return my_string.start_with?(substr)
end
print check_string("JavaScript", "Java")
print "\n",check_string("Python", "PHP")

Output:

true
false

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now