Ruby we might Miss

Posted on August 9, 2011

0


Hi.
This is a small series of posts about some everyday ruby we might miss but is very important.
I am going through Advanced Rails book.
I will be posting what I find very interesting !!
Every post will cover a major class:

Topic for this post :
Array.

(Sorry for poor formatting !! )
———————————————————————————————————————————–
Array#* can operate as Array#join (if given a string or stringlike argument); it also does
repetition:
[1, 2, 3] * “; ” # => “1; 2; 3”
[0] * 5 # => [0, 0, 0, 0, 0]
———————————————————————————————————————————–

———————————————————————————————————————————–

Array#pack and String#unpack are useful for working with binary files. why the lucky
stiff uses Array#pack to stuff a series of numbers into a BMP-formatted sparkline graph
without any heavy image libraries, in 13 lines of code (http://redhanded.hobix.com/
inspect/sparklinesForMinimalists.html).

———————————————————————————————————————————–

Posted in: Ruby