I recently discovered that alongside with `is' there exists `is#' operator which is convenient for checking whether given variable is equal to some string while you don't know what is the type of this variable. I guess it should be documented. Also added a tag for `isnot' and a note about possibility of comparing variables with different types without errors and explicit type checks.
# HG changeset patch # User ZyX <[email protected]> # Date 1306176068 -14400 # Node ID cb05f3591407aa72e4524ed4f002c1c4a7a19d36 # Parent f0cc719cd12900f22deaa153debf49eecc28399d Added is# documentation
diff -r f0cc719cd129 -r cb05f3591407 runtime/doc/eval.txt --- a/runtime/doc/eval.txt Thu May 19 18:26:40 2011 +0200 +++ b/runtime/doc/eval.txt Mon May 23 22:41:08 2011 +0400 @@ -715,13 +715,14 @@ Compare two expr5 expressions, resulting in a 0 if it evaluates to false, or 1 if it evaluates to true. - *expr-==* *expr-!=* *expr->* *expr->=* - *expr-<* *expr-<=* *expr-=~* *expr-!~* - *expr-==#* *expr-!=#* *expr->#* *expr->=#* - *expr-<#* *expr-<=#* *expr-=~#* *expr-!~#* - *expr-==?* *expr-!=?* *expr->?* *expr->=?* - *expr-<?* *expr-<=?* *expr-=~?* *expr-!~?* - *expr-is* + *expr-==* *expr-!=* *expr->* *expr->=* + *expr-<* *expr-<=* *expr-=~* *expr-!~* + *expr-==#* *expr-!=#* *expr->#* *expr->=#* + *expr-<#* *expr-<=#* *expr-=~#* *expr-!~#* + *expr-==?* *expr-!=?* *expr->?* *expr->=?* + *expr-<?* *expr-<=?* *expr-=~?* *expr-!~?* + *expr-is* *expr-isnot* *expr-is#* *expr-isnot#* + *expr-is?* *expr-isnot?* use 'ignorecase' match case ignore case ~ equal == ==# ==? not equal != !=# !=? @@ -731,8 +732,8 @@ smaller than or equal <= <=# <=? regexp matches =~ =~# =~? regexp doesn't match !~ !~# !~? -same instance is -different instance isnot +same instance is is# is? +different instance isnot isnot# isnot? Examples: "abc" ==# "Abc" evaluates to 0 @@ -753,12 +754,13 @@ A |Funcref| can only be compared with a |Funcref| and only "equal" and "not equal" can be used. Case is never ignored. -When using "is" or "isnot" with a |List| this checks if the expressions are -referring to the same |List| instance. A copy of a |List| is different from -the original |List|. When using "is" without a |List| it is equivalent to -using "equal", using "isnot" equivalent to using "not equal". Except that a -different type means the values are different. "4 == '4'" is true, "4 is '4'" -is false. +When using "is" or "isnot" with a |List| or a |Dictionary| this checks if the +expressions are referring to the same |List| or |Dictionary| instance. A copy +of a |List| is different from the original |List|. When using "is" without +a |List| or a |Dictionary| it is equivalent to using "equal", using "isnot" +equivalent to using "not equal". Except that a different type means the +values are different: "4 == '4'" is true, "4 is '4'" is false and "0 is []" is +false and not a error. When comparing a String with a Number, the String is converted to a Number, and the comparison is done on Numbers. This means that "0 == 'x'" is TRUE,
signature.asc
Description: This is a digitally signed message part.
