0
Pig Latin, Error Code
New to coding....It is giving me an error on the word “new”. I keep tweeking little things but I can not get it to run. I added notes just to make sure my thinking was correct. What am I missing? user=gets.chomp #split words into array of substrings words=user.split("") words.new = [] words.each do |word| #take away one index base = words.length - 1 #start at index 1 until (index -1) count ends, add first letter, add "ay" words.new << (word[1..base] + word[0] + "ay") end puts words.new.join ("")
2 odpowiedzi
+ 2
Joy Shadburn , the array initialization in your code is wrong. Either use for example words = [] or words = Array.new. At the end join the new words by whitespace. Look at the corrected code. Hope it helps you.
https://code.sololearn.com/c57Hs7Xn0B6z/?ref=app
0
TheWh¡teCat 🇧🇬 Thank you, I’m glad at least the majority of my code was right. Only been coding for three weeks so this helps.