KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
How do I get the following to happen: I want to change the value of an array element which is being referenced between pipe characters in a .each loop. Here is an example of what I want to do, but is not currently working: x = %w(hello there world) x.each { |element| if(element == "hello") { element = "hi" # change "hello" to "hi" } } puts x # output: [hi there world] It's hard to look up something so general.
Tags (comma-separated)
Save Edits
Cancel