# Doubt in -- Ruby --\> Array --\> array.display -- method

**URL:** <https://www.ruby-forum.com/t/doubt-in-ruby-array-array-display-method/161653>\
**Category:** Ruby\
**Created:** [February 28, 2009, 1:15pm UTC](https://www.ruby-forum.com/t/doubt-in-ruby-array-array-display-method/161653 "2009-02-28T13:15:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jazzezravi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/71e660/32.png) [@jazzezravi](https://www.ruby-forum.com/u/jazzezravi)\
**Post date:** [February 28, 2009, 1:15pm UTC](https://www.ruby-forum.com/t/doubt-in-ruby-array-array-display-method/161653/1 "2009-02-28T13:15:31Z")

</div>

Hi All,

I created few (array’s method related) questions in ruby. But I am not  
clear about one question. Here is the question …

Question 7  
(from  
[Ruby — Array related Excercise – Raveendran](http://raveendran.wordpress.com/2009/02/18/ruby-array-related-excercise/))

@a=[34,45,56,2,13,54]

@b= @a[2].display.to\_i + @a[3].display.to\_i

puts @b gives,

a) Error b) 58 c) 5620 d) 562

This is the question. In my view,

MY Solution 1:

@a[2].display.to\_i =\> 56.display gives 56.to\_i =\> 56  
@a[3].display.to\_i =\> 2.diaply gives 2.to\_i =\> 2

@b= 56 + 2

@b must come as 58

MY Solution 2:

56.display → displays 56 → Here .to\_i will not work

So my answers is,

@b= 562

But the result came as 5620 . how it works ?

Thanks,  
P.Raveendran

---

<div class="post-metadata">

**Author:** ![jazzezravi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/71e660/32.png) [@jazzezravi](https://www.ruby-forum.com/u/jazzezravi)\
**Post date:** [February 28, 2009, 2:09pm UTC](https://www.ruby-forum.com/t/doubt-in-ruby-array-array-display-method/161653/2 "2009-02-28T14:09:04Z")

</div>

jazzez ravi wrote:

> Hi All,
> 
> I created few (array’s method related) questions in ruby. But I am not  
> clear about one question. Here is the question …
> 
> Question 7  
> (from  
> [Ruby — Array related Excercise – Raveendran](http://raveendran.wordpress.com/2009/02/18/ruby-array-related-excercise/))
> 
> @a=[34,45,56,2,13,54]
> 
> @b= @a[2].display.to\_i + @a[3].display.to\_i
> 
> puts @b gives,
> 
> a) Error b) 58 c) 5620 d) 562
> 
> This is the question. In my view,  
> (…)
> 
> MY Solution 2:
> 
> 56.display → displays 56 → Here .to\_i will not work
> 
> So my answers is,
> 
> @b= 562
> 
> But the result came as 5620 . how it works ?
> 
> Thanks,  
> P.Raveendran

56.display → prints 56 and returns nil.  
nil.to\_i returns 0  
So @b equals zero

hth,

Siep
