The syntax obj <- {} caught my eye in this post https://stackoverflow.com/a/3417894/168689. I’m fairly new to R and hadn’t seen it before so I fired up my console:
obj <- {}
class(obj)
and found an object of class NULL.
class(obj)
[1] "NULL"
I’d like to know the opinions on this technique in the R community. Is there merit in it? Do the possible downsides (really, no class?) outweigh those?
{}is equivalent toNULL. Noteidentical({}, NULL)isTRUE.NULLis clearer, imo, but there are no repercussions to using{}instead—except maybe the risk of inducing momentary confusion on someone reviewing your code.