# Quizzical?

**URL:** <https://www.ruby-forum.com/t/quizzical/127653>\
**Category:** Ruby\
**Created:** [January 31, 2008, 3:20am UTC](https://www.ruby-forum.com/t/quizzical/127653 "2008-01-31T03:20:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Wyatt\_G](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/53a042/32.png) [@Wyatt\_G](https://www.ruby-forum.com/u/Wyatt_G)\
**Post date:** [January 31, 2008, 3:20am UTC](https://www.ruby-forum.com/t/quizzical/127653/1 "2008-01-31T03:20:59Z")

</div>

Can you guess what this program will do when run?

a = ???:???:??:???:??  
puts a

Feel free to post answers and spoilers to this below. If you don’t  
want to see the answer, stop reading! 🙂

---

<div class="post-metadata">

**Author:** ![Wyatt\_G](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/53a042/32.png) [@Wyatt\_G](https://www.ruby-forum.com/u/Wyatt_G)\
**Post date:** [January 31, 2008, 3:45am UTC](https://www.ruby-forum.com/t/quizzical/127653/2 "2008-01-31T03:45:39Z")

</div>

On Jan 30, 7:15 pm, Wyatt G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Can you guess what this program will do when run?
> 
> a = ???:???:??:???:??  
> puts a
> 
> Feel free to post answers and spoilers to this below. If you don’t  
> want to see the answer, stop reading! 🙂

It’s either going to be 58 or 63, is my guess before IRB. 🙂

---

<div class="post-metadata">

**Author:** ![Wyatt\_G](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/53a042/32.png) [@Wyatt\_G](https://www.ruby-forum.com/u/Wyatt_G)\
**Post date:** [January 31, 2008, 3:55am UTC](https://www.ruby-forum.com/t/quizzical/127653/3 "2008-01-31T03:55:37Z")

</div>

On Jan 30, 9:15 pm, Wyatt G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Can you guess what this program will do when run?
> 
> a = ???:???:??:???:??  
> puts a
> 
> Feel free to post answers and spoilers to this below. If you don’t  
> want to see the answer, stop reading! 🙂

I guess same as a = ?? ? ?? : _any_

---

<div class="post-metadata">

**Author:** ![Wyatt\_G](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/53a042/32.png) [@Wyatt\_G](https://www.ruby-forum.com/u/Wyatt_G)\
**Post date:** [January 31, 2008, 8:15am UTC](https://www.ruby-forum.com/t/quizzical/127653/4 "2008-01-31T08:15:54Z")

</div>

Wyatt G. wrote:

> Can you guess what this program will do when run?
> 
> a = ???:???:??:???:??

a = ?? ? ?? : ?? ? ?? ? ?? : ?? : ?? ? ?? : ??  
It’s pretty clear to see that this will return ??(63) without looking  
further  
into the structure of the code, but let’s take a closer look at the  
order in  
which the ternaries are executed anyway:  
a = ?? ? (??) : (?? ? (?? ? ?? : ??) : (?? ? ?? : ??))  
So we have:  
if 63  
63  
else  
if 63  
if 63  
63  
else  
63  
end  
else  
if 63  
63  
else  
63  
end  
end  
end  
Result: 63
