Feature Overview
This feature adds support for nullable variables.
This feature adds support for nullable variables.
None
public class NullableDemo {
public static void main() {
String s1 = 'abc';
Integer i1 = s1.length();
String s2 = null;
Integer i2 = s2?.length();
Integer i3 = ('a' + 'b')?.length();
}
}
public class NullableDemo {
public static void main() {
String s1 = 'abc';
Integer i1 = s1.length();
String s2 = null;
Integer i2 = (s2 != null ? s2.length() : null);
Integer i3 = (('a' + 'b') != null ? ('a' + 'b').length() : null);
}
}
Use nullable variables in method invocations or field accesses.
Try not using nest nullable variables as this will increase complexity.
Contribute on Github! Edit this section.