DEV Community

es404020
es404020

Posted on

Ruby Arrays

Array is a container made up of rows and col .In which every row and col denote a unique position in the container .Take for instance a prison .Each cell(col) in a prison belong to a block (row) which can be uniquely identified.

In ruby array are denote as

a = [1,3,4,6,7,8]


Enter fullscreen mode Exit fullscreen mode

Ruby also have a lot of function to manipulate an array .To make this blog interesting let make it a quiz.

Quiz
a.length-
a.last
a.first
a.select {|number| number.odd?}
a.joint("-")
a.split(" ")
%w{"my name is eniola ajani solomon")

Array loop

each

a.each do |value|
     puts value 
end



Enter fullscreen mode Exit fullscreen mode

for


for i in a 
   puts i
end 

```

`
To get more array method

```
a.methods
```
Thanks for reading 
Enter fullscreen mode Exit fullscreen mode

Top comments (0)