Newsgroups: comp.lang.smalltalk
Path: cantaloupe.srv.cs.cmu.edu!rochester!udel!news.mathworks.com!news.alpha.net!uwm.edu!math.ohio-state.edu!howland.reston.ans.net!cs.utexas.edu!news.ti.com!ticipa!clw
From: clw@ticipa.pac.sc.ti.com (Chris Winemiller)
Subject: Re: Smalltalk/V question
Message-ID: <1995Feb24.154437.1395@ticipa.pac.sc.ti.com>
Organization: None
References: <3iavig$fm1@haida.pro.net>
Date: Fri, 24 Feb 1995 15:44:37 GMT
Lines: 41

In article <3iavig$fm1@haida.pro.net> viboonc@paradigm.bc.ca (Viboon) writes:
>Hi Everyone,
>
>   I am a new Smalltalk/V user (windows version) and have
>a question:
>
>   How can I write the following C statement in Smalltalk
>elegantly:
>
>   if ( (char1=='t' || char1=='T') &&
>        (char2=='h' || char2=='H') &&
>        (char3=='e' || char3=='E') ) { ..... }

How about this:

| myString |
myString := String with: char1 with: char2 with: char3.
myString asLowerCase = 'the'
  ifTrue: [ .... ].

Or a slight variation (since you're using Smalltalk/V):

| mystring |
myString := String with: char1 with: char2 with: char3.
(myString equalsIgnoreCase: 'the')
  ifTrue: [ .... ].

Or yet another variation:

(         char1 asLowerCase = $t
    and: [char2 asLowerCase = $h
    and: [char3 asLowerCase = $e  ]])
ifTrue: [ .... ]

Regards,
Chris
==============================================================
Chris Winemiller               Internet: clw@works.ti.com
Disclaimer: I do not speak for TI.
==============================================================

