testing a String argument

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

testing a String argument

Mark Volkmann
What's the best way to set a local variable to true if an argument  
that is supposed to be a String isn't nil and has a size of at least  
1? I know I can do this.

hasContent := aString notNil and: [ aString isEmpty not ].

but it feels like I'm making this simple test too hard.

---
Mark Volkmann




_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: testing a String argument

Bert Freudenberg

Am 02.10.2008 um 12:20 schrieb Mark Volkmann:

> What's the best way to set a local variable to true if an argument  
> that is supposed to be a String isn't nil and has a size of at least  
> 1? I know I can do this.
>
> hasContent := aString notNil and: [ aString isEmpty not ].
>
> but it feels like I'm making this simple test too hard.


Use #isEmptyOrNil.

- Bert -

_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners