how can I replace one single element in an array in ruby? so that an array
days=["monday", "tuesday", "wednesday", "jueves"] #so "jueves" gets replaced by the string "thursday"
thanks
You an also do...
days.map!{|day| day == "jueves" ? "thursday" : day}
m-p's answer will replace the first occurrence, this will replace all occurrences.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With