Testing for NULL
- Posted by xecronix Sep 02, 2015
- 2011 views
#!/usr/bin/env eui sequence x -- The next executable line is an error as expected. -- But, how can I test/defend against this error in advance? -- ie -- -- if x = ??? then -- -- do something -- end if printf(1, "x is %s", {x}) -- How to test for this error? -- No problem here. Works as I expected x = "some sequence" printf(1, "x is %s\n", {x}) -- I don't know how to express this in Euphoria either. -- What I hoped for was a way to set x to some value -- after valid assignment that would cause the error at the -- start of the code. x = 0 -- This causes a type error. But how do you unset a variable? printf(1, "x is %s\n", {x})
This came up when I wanted to do this
public function fname(sequence self, sequence x = 0) if x then self[FNAME] = x end if return self[FNAME] end function