Joining arrays, the ruby way
Thu, 02/02/2012 - 23:14
in
Like PHP's join function but in more elegant ruby way. Let's see how can you do it:
[1, 2, 3, 4, 5].join(',')
Or:
[1, 2, 3, 4, 5] * ','
Yes, the multiply operator does the job as well.
Or:
(1..5).to_a * ','
All times the same result:
=> "1,2,3,4,5"
I never play videogames, but with programming languages in My free time, hope You enjoy reading.
- sandor's blog
- Login to post comments
Welcome at my blog section! You can find my interests here. Maybe in my mother-language or in english, the choice is mine, but I hope you will spend nice amusement here.
This blog is about:
- Programming
- Motorcycling
- Paragliding
- Gardening
sandor's tweets
- How many tricks of these you already know? Me only few. http://t.co/kcRTEjgd — 11 hours 53 min ago
- Fight for Scottish Independence, but not for the republic! http://t.co/EXuWxhU5 — 12 hours 35 min ago
- Just switched to NetworkManager on Archlinux. I circumambulating it, but connecting to a VPN network is only two clicks. — 15 hours 58 min ago
- jQuery scoll effects. http://t.co/a5Ym9GPD — 1 day 10 hours ago
- jQuery file upload demo. http://t.co/sOl4F79u — 1 day 11 hours ago
- Just posted a photo http://t.co/75z4uOvq — 1 day 17 hours ago
- Sublime Text 2 tips. I really like this editor btw. http://t.co/aN88Duy8 — 2 days 10 hours ago
- http://t.co/SKTbSTTw Great idea — 2 days 10 hours ago
- 1 of 82
- ››
