Introducing Ruby Array
1) Ruby Array is collection of objects that do not need to be the same type. That means, ruby array class can hold Fixnum, float, string, etc objects in the same array. The following peace of code:
Will return
Fixnum
Float
String
Array
=> [1, 1.2, "2", [1, 2, 4]]
2) Ruby arrays can be concatenated using + sign, for example
arr3 will be [1, 2, 3, 4]
3) Ruby array is quite circular. Ruby Array allows reverse index; negative index.
The previous peace of code going to return 6 which is located at index = -1.
4) Ruby Array has the following methods
& * + - << <=> == [] [] []= abbrev assoc at clear collect collect! compact compact! concat dclone delete delete_at delete_if each each_index empty? eql? fetch fill first flatten flatten! frozen? hash include? index indexes indices initialize_copy insert inspect join last length map map! new nitems pack pop pretty_print pretty_print_cycle push quote rassoc reject reject! replace reverse reverse! reverse_each rindex select shift size slice slice! sort sort! to_a to_ary to_s to_yaml transpose uniq uniq! unshift values_at yaml_initialize zip |








