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

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

Your comment: