Tcl 8.5: in & ni

(Printer friendly version)

Once upon a time (Tcl 7.x; probably earlier too?) the best way to test for string equality in Tcl was:

if {[string compare $x $y] == 0} ...

Beginning with Tcl 8.1.1 the preferred way became:

if {[string equal $x $y]} ...

Beginning with Tcl 8.4 and the introduction of the eq and ne operators testing for string equality became much more concise:

if {$x eq $y} ...

Much more readable, concise, and less to type. In Tcl 8.5 we get a simillar improvement for testing whether a particular item is a member (or not) of a list:

if {$x in $y} ...

Which IMHO is a huge improvement over the former idiom:

if {[lsearch -exact $y $x] != -1} ...

Naturally ni is to ne as in is to eq. And to top it all off, ni is fun to say too.

—Michael A. Cleverly

Comments

sara: [ mail | www | link ]

I read a article under the same title some time ago, but this articles quality is much, much better. How you do this..

Sun, 15 Jan 2023, 06:51

abdul rehman: [ mail | www | link ]
i read a considerable measure of stuff and i found that the method for composing to clearifing that precisely need to say was great so i am inspired and ilike to come back again in future.. Tunxis Country Club wedding photos

Sat, 21 Oct 2023, 04:50

Leave a comment

Name:  
Email: (optional)
URL: (optional)

Your comment: