Empty string: Difference between revisions

Added the Common Lisp version after the CoffeeScript one
(Added the Common Lisp version after the CoffeeScript one)
Line 166:
console.log (s = '') == "" # true
console.log new String() == '' # false, due to underlying JavaScript's distinction between objects and primitives
</lang>
 
=={{header|Common Lisp}}==
Common Lisp treats empty strings as true (T in Common Lisp), therefore one must check the length of the string to know if it is empty or not.
<lang lisp>
(defparameter *s* "") ;; Binds dynamic variable *S* to the empty string ""
(let ((s "")) ;; Binds the lexical variable S to the empty string ""
(= (length s) 0) ;; Check if the string is empty
(> (length s) 0)) ;; Check if length of string is over 0 (that is: non-empty)
</lang>
 
Anonymous user