This commit is contained in:
Ingy döt Net 2013-04-10 21:29:02 -07:00
parent 764da6cbbb
commit db842d013d
19005 changed files with 197040 additions and 7 deletions

View file

@ -0,0 +1,5 @@
a := "" // assign an empty string to 'a'
a.isEmpty // method on sys::Str to check if string is empty
a.size == 0 // what isEmpty actually checks
a == "" // alternate check for an empty string
!a.isEmpty // check that a string is not empty

View file

@ -0,0 +1,5 @@
def s = '' // or "" if you wish
assert s.empty
s = '1 is the loneliest number'
assert !s.empty

View file

@ -0,0 +1,16 @@
s := "" # null string
s := string('A'--'A') # ... converted from cset difference
s := char(0)[0:0] # ... by slicing
s1 == "" # lexical comparison, could convert s1 to string
s1 === "" # comparison won't force conversion
*s1 = 0 # zero length, however, *x is polymorphic
*string(s1) = 0 # zero length string
s1 ~== "" # non null strings comparisons
s1 ~=== ""
*string(s1) ~= 0
s := &null # NOT a null string, null type
/s # test for null type
\s # test for non-null type

View file

@ -0,0 +1,5 @@
variable=: ''
0=#variable
1
0<#variable
0

View file

@ -0,0 +1,5 @@
variable: ""
0=#variable
1
0<#variable
0

View file

@ -0,0 +1,9 @@
HAI 1.3
I HAS A string ITZ ""
string, O RLY?
YA RLY, VISIBLE "STRING HAZ CONTENZ"
NO WAI, VISIBLE "Y U NO HAS CHARZ?!"
OIC
KTHXBYE

View file

@ -0,0 +1,3 @@
make "str " ;make null-string word
print empty? :str ;prints 'true'
print not empty? :str ;prints 'false'

View file

@ -0,0 +1,8 @@
'assign empty string to variable
a$ = ""
'check for empty string
if a$="" then print "Empty string."
if len(a$)=0 then print "Empty string."
'check for non-empty string
if a$<>"" then print "Not empty."
if len(a$)>0 then print "Not empty."

View file

@ -0,0 +1,3 @@
str=""; (*Create*)
str==="" (*test empty*)
str=!="" (*test not empty*)

View file

@ -0,0 +1,9 @@
s: ""$
/* check using string contents */
sequal(s, "");
not sequal(s, "");
/* check using string length */
slength(s) = "";
slength(s) # "";

View file

@ -0,0 +1,6 @@
empty_string1 = ""
empty_string2 = String.new
puts "empty string is empty" if empty_string1.isEmpty()
puts "empty string has no length" if empty_string2.length() == 0
puts "empty string is not nil" unless empty_string1 == nil