type
test = tuple[t1:int,t2:int32]
var tpl:test
if tpl == nil: #complile error: Error: type mismatch: got (test, nil)
echo "tuple is nil"
it seems tuple, array can not be null.
gist.nim(10, 8) Error: type mismatch: got (test, nil)
but expected one of:
system.==(x: bool, y: bool)
system.==(x: cstring, y: cstring)
system.==(x: T, y: T)
system.==(x: float, y: float)
system.==(x: ref T, y: ref T)
system.==(x: int16, y: int16)
system.==(x: int8, y: int8)
system.==(x: ptr T, y: ptr T)
system.==(x: float32, y: float32)
system.==(x: char, y: char)
system.==(x: pointer, y: pointer)
system.==(x: T, y: T)
system.==(x: int64, y: int64)
system.==(x: set[T], y: set[T])
system.==(x: string, y: string)
system.==(x: T, y: T)
system.==(x: int, y: int)
system.==(x: Enum, y: Enum)
system.==(x: int32, y: int32)
system.==(x: seq[T], y: seq[T])
system.==(x: array[I, T], y: array[I, T])
tables.==(s: TableRef[==.A, ==.B], t: TableRef[==.A, ==.B])
tables.==(s: Table[==.A, ==.B], t: Table[==.A, ==.B])
asyncdispatch.==(x: AsyncFD, y: AsyncFD)
os.==(err1: OSErrorCode, err2: OSErrorCode)
but when I use jester:
#MultiData* = Table[string, tuple[fields: StringTableRef, body: string]]
let tpl = request.formData.getOrDefault("not_exist_key")
let fn = tpl.fields.getOrDefault("filename") #ERROR
nil error occurred,
I want to know HOW TO KNOW tuple is empty or nil ,thank you!
A tuple is never nil, neither can it be empty. tpl.fields, however, is a StringTableRef and therefore can be nil. You have to check:
if tpl.fields == nil:
echo "tpl.fields is nil!"