[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Quizzical?

Wyatt Greene

1/31/2008 2:16:00 AM

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! :)







3 Answers

Phrogz

1/31/2008 2:43:00 AM

0

On Jan 30, 7:15 pm, Wyatt Greene <green...@yahoo.com> 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. :)

Sergey Volkov

1/31/2008 2:54:00 AM

0

On Jan 30, 9:15 pm, Wyatt Greene <green...@yahoo.com> 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_

Sebastian Hungerecker

1/31/2008 7:14:00 AM

0

Wyatt Greene 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


--
Jabber: sepp2k@jabber.org
ICQ: 205544826