asUppercase doesn't work

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

asUppercase doesn't work

alaztetik
This post has NOT been accepted by the mailing list yet.
Hi everbody,

It is nice to be here with you. This is my first post and I'm very excited!

I'm reading "Squeark by Example" book and encountered an interesting error.

---

I created a method named "testString" and here is its content:

testShout
        ^self asUppercase, '!'.

When I test it, it doesn't work and gives this error: doesNotUnderstand:#asUppercase.

But when I replace the text:

testShout
        ^self opy asString translateToUppercase, '!'

It works! Where am I making a mistake?
Reply | Threaded
Open this post in threaded view
|

Re: asUppercase doesn't work

Joseph Alotta
It works for me (I did this in the workspace) :

'test' class ==>  ByteString

'test' asUppercase ==> ‘TEST'

It is difficult to tell from your email what is the problem.   I would recommend that you test little things like
this in a workspace window.  I am suspecting that your method is not being called in the way you think it is.


Sincerely,

Joseph.



> On Mar 8, 2017, at 1:21 PM, alaztetik [via Smalltalk] <[hidden email]> wrote:
>
> Hi everbody,
>
> It is nice to be here with you. This is my first post and I'm very excited!
>
> I'm reading "Squeark by Example" book and encountered an interesting error.
>
> ---
>
> I created a method named "testString" and here is its content:
>
> testShout
>         ^self asUppercase, '!'.
>
> When I test it, it doesn't work and gives this error: doesNotUnderstand:#asUppercase.
>
> But when I replace the text:
>
> testShout
>         ^self opy asString translateToUppercase, '!'
>
> It works! Where am I making a mistake?
>
> If you reply to this email, your message will be added to the discussion below:
> http://forum.world.st/asUppercase-doesn-t-work-tp4937922.html
> To start a new topic under Squeak - Beginners, email [hidden email]
> To unsubscribe from Squeak - Beginners, click here.
> NAML

Reply | Threaded
Open this post in threaded view
|

Re: asUppercase doesn't work

Ben Coman
On Thu, Mar 9, 2017 at 5:07 AM, Joseph Alotta <[hidden email]> wrote:

> It works for me (I did this in the workspace) :
>
> 'test' class ==>  ByteString
>
> 'test' asUppercase ==> ‘TEST'
>
> It is difficult to tell from your email what is the problem.   I would
> recommend that you test little things like
> this in a workspace window.  I am suspecting that your method is not being
> called in the way you think it is.
>
>
> Sincerely,
>
> Joseph.
>
>
>
>> On Mar 8, 2017, at 1:21 PM, alaztetik [via Smalltalk] <[hidden email]>
>> wrote:
>>
>> Hi everbody,
>>
>> It is nice to be here with you. This is my first post and I'm very
>> excited!
>>
>> I'm reading "Squeark by Example" book and encountered an interesting
>> error.
>>
>> ---
>>
>> I created a method named "testString" and here is its content:
>>
>> testShout
>>         ^self asUppercase, '!'.
>>
>> When I test it, it doesn't work and gives this error:
>> doesNotUnderstand:#asUppercase.

What class is reported as not understanding #asUpperCase ?
Given that your method starts with "test..."
I'd expect its in a class that is subclassed from TestCase.
But if you look at the "Implementors" of #asUpperCase (select the text
and hit <CTRL-M>)
you'll see #asUpperCase is only understood by Character, String & WideString.

So is "self" a-TestCase ?
To investigate, you can put a "self halt" at the top of the method,
and in the debugger, select self and "Inspect it".

btw, Can you supply a link and page reference for Squeak by Example?

cheers -ben

>>
>> But when I replace the text:
>>
>> testShout
>>         ^self opy asString translateToUppercase, '!'
>>
>> It works! Where am I making a mistake?
>>
>> If you reply to this email, your message will be added to the discussion
>> below:
>> http://forum.world.st/asUppercase-doesn-t-work-tp4937922.html
>> To start a new topic under Squeak - Beginners, email [hidden email]
>> To unsubscribe from Squeak - Beginners, click here.
>> NAML
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners