Jon every Odd element in an array in ruby
I learned about join today from This question I asked and did some
research into arrays with ruby. I decided that my array could contain some
extra info to look like this:
arr = ["object 1", 3, "object 2", 6]
with this I thought I could use join() to create an out put that is:
object 1 (x3), object 2 (x6).
But upon reading about join it doesnt look look like I can do that. I then
started reading up on how to get odd or even values in ruby arrays but I
am not sure this is what I want either.
How can I create the expected out put above? is there a simple way using
.join()?
No comments:
Post a Comment