1b25f598ff48

ints
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Mon, 10 Oct 2011 00:28:56 -0400
parents 29be75a733f5
children 310f014b7beb
branches/tags (none)
files chapters/22.markdown

Changes

--- a/chapters/22.markdown	Mon Oct 10 00:17:18 2011 -0400
+++ b/chapters/22.markdown	Mon Oct 10 00:28:56 2011 -0400
@@ -94,9 +94,9 @@
 user has set" comparison operator.  Now run the following command:
 
     :set ignorecase
-    :if "foo" ==? "FOO"
+    :if "foo" ==# "FOO"
     :    echom "one"
-    :elseif "foo" ==? "foo"
+    :elseif "foo" ==# "foo"
     :    echom "two"
     :endif
 
@@ -107,6 +107,16 @@
 or insensitive comparisons.  Using the normal forms is *wrong* and it *will*
 break at some point.  Save yourself the trouble and type the extra character.
 
+When you're comparing integers this distinction obviously doesn't matter.
+Still, I feel that it's better to use the case-sensitive comparisons everywhere,
+even where they're not needed, than to forget them in a place that they *are*
+needed.
+
+Using `==#` and `==?` with integers will work just fine, and if you change them
+to strings in the future it will work correctly.  If you'd rather use `==` for
+integers that's fine, but you need to remember to you change the comparison if
+you change them to strings in the future.
+
 Exercises
 ---------