Null object: Difference between revisions
J: attempt to more adequately describe how we fill in the holes in the description of holes as represented in the language
m (→{{header|K}}) |
(J: attempt to more adequately describe how we fill in the holes in the description of holes as represented in the language) |
||
Line 470:
=={{header|J}}==
J doesn't have an untyped NULL. Instead, it has a concept of "fill". Numeric fill is 0, character fill is the space character, and boxed fill is the ace (a:) which is an empty box. Fill is what is used to pad an array structure when that is needed. (And some operations support using a user specified value in place of the default fill.)
J doesn't have NULL. To indicate "missing data", "normal" data is usually pressed into service (e.g. <tt>0</tt> or <tt>_1</tt> in a numeric context, <tt>' '</tt> in a literal context, <tt>a:</tt> in a boxed context, etc). Frequently, missing data is represented by the empty vector <tt><nowiki>''</nowiki></tt>, or other arrays without any elements.▼
▲
That said, undefined names in J are not associated with any data of any type. Furthermore, any attempt to use the value of an undefined is treated as an error (this is distinct from the concept of an empty array, which contains no data but which is not an error to use). However, it is possible to check if a name is defined before attempting to use it:
<lang J>isUndefined=: _1 = nc@boxxopen</lang>
Line 484 ⟶ 486:
0</lang>
Note,
:Marie Pennysworth, having spent a productive day shopping, stopped by Robert Cuttingham's butcher shop.
Line 498 ⟶ 500:
:He smiled, "When I am out, I only charge seven dollars a pound."
That said, note that
<lang j> 1 1 0 1#3 4 _ 5
|