Unexpected success in string concatenation

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Unexpected success in string concatenation

Richard Sargent
Administrator
I was reviewing some code in the GBS tester when I came across the equivalent of
'Test failed because ', Object new

I was surprised that worked, so I looked into it. I'm posting this so that others will be aware of this potentially unexpected behaviour.


It succeeds since the variable size of an arbitrary object is zero. The concatenation method doesn't care that the receiver is bytes and the argument is objects. There are zero of them to add to the concatenation, so it quietly works.


I do think the behaviour is correct.

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/va-smalltalk/f7a5108c-9477-400a-b1cb-87a7f5620788%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Unexpected success in string concatenation

Wayne Johnston
Cute.  These also work:

'Test failed because ', 5.
'Test failed because ', nil.
'Test failed because ', [self halt]. 

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/va-smalltalk/32dadd01-d4f0-48db-b234-d25c41e38e21%40googlegroups.com.