Is the idea of Swift's "implicitly unwrapped optionals" the same as Java's "autoboxing" of integers? The following runtime exception would only be possible in Swift if xObj
is declared an "implicitly unwrapped option":
Integer xObj = new Integer(-1);
xObj = null; // could do this with an implicitly unwrapped optional as well.
Integer.valueOf(xObj); // <-- exception. Integer.valueOf(int x); couldn't deal with this.
The point being that "implicitly unwrapped optionals" CAN be nil, but you better be careful and not use them when a non-nil reference is expected, right?