aeonsky Posted November 1, 2008 Share Posted November 1, 2008 Hey everyone. just having trouble understanding this... array = ["Hello", "there", "sweetie", 1, 2, 3] array[1, 2] = "here" puts array Outputs... Hello here 1 2 3 I have no idea why, where does "sweetie" go? I would assume the output to be this... Hello here here 1 2 3 Thanks for the help. Link to comment https://forums.phpfreaks.com/topic/131000-solved-quick-ruby-help/ Share on other sites More sharing options...
Mchl Posted November 1, 2008 Share Posted November 1, 2008 I might be wrong, because I had only a very quick on ruby some months ago, but it seems that [edit] Yeah, I was wrong. What was here was just silly Link to comment https://forums.phpfreaks.com/topic/131000-solved-quick-ruby-help/#findComment-680080 Share on other sites More sharing options...
aeonsky Posted November 2, 2008 Author Share Posted November 2, 2008 OK, never mind guys, I got it. For anyone who is new to Ruby too, here is what happens. array[1, 2] Selects two elements and then changes it to the string you specified. Since there is only one string, it produces only one element. So if you want to produce this... Hello here here 1 2 3 You need to do this... array[1, 2] = "here", "here" Link to comment https://forums.phpfreaks.com/topic/131000-solved-quick-ruby-help/#findComment-680308 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.