Quizzical?

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

On Jan 30, 7:15 pm, Wyatt G. [email protected] 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! :slight_smile:

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

On Jan 30, 9:15 pm, Wyatt G. [email protected] 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! :slight_smile:

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

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