How can I check for first letter(s) in string in Ruby?
I'm writing test file, but I can't get it pass second test, here:
if word.start_with?('a','e','i','o','u')
word << "ay"
else
word << "bay"
end
Is start_with? the right method to do the job?
describe "#translate" do
it "translates a word beginning with a vowel" do
s = translate("apple")
s.should == "appleay"
end
it "translates a word beginning with a consonant" do
s = translate("banana")
s.should == "ananabay"
end
it "translates a word beginning with two consonants" do
s = translate("cherry")
s.should == "errychay"
end
end
No comments:
Post a Comment