From 8b7a7cbc813653a3248d6cf3a7779e220957bc85 Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Mon, 8 May 2017 21:28:02 +0200 Subject: The great rename: the old ‘website’ is now ‘website-old’, and ‘website2’ is now ‘website’. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- website-old/features/val.html | 76 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 website-old/features/val.html (limited to 'website-old/features/val.html') diff --git a/website-old/features/val.html b/website-old/features/val.html new file mode 100644 index 00000000..82c96b39 --- /dev/null +++ b/website-old/features/val.html @@ -0,0 +1,76 @@ + + + + + + + + val +
+
+
+ +

val

+ +
+

Overview

+

+ NEW in Lombok 0.10: You can use val as the type of a local variable declaration instead of actually writing the type. When you do this, + the type will be inferred from the initializer expression. The local variable will also be made final. This feature works + on local variables and on foreach loops only, not on fields. The initializer expression is required. +

+ val is actually a 'type' of sorts, and exists as a real class in the lombok package. You must import it for val to work (or use lombok.val as the type). + The existence of this type on a local variable declaration triggers both the adding of the final keyword as well as copying the type of the initializing expression which overwrites + the 'fake' val type. +

+ WARNING: This feature does not currently work in NetBeans. We're working on fixing that. +

+
+
+
+

With Lombok

+
@HTML_PRE@
+
+
+
+

Vanilla Java

+
@HTML_POST@
+
+
+
+
+

Supported configuration keys:

+
+
lombok.val.flagUsage = [warning | error] (default: not set)
+
Lombok will flag any usage of val as a warning or error if configured.
+
+
+
+

Small print

+

+ For compound types, the most common superclass is inferred, not any shared interfaces. For example, bool ? new HashSet() : new ArrayList() + is an expression with a compound type: The result is both AbstractCollection as well as Serializable. The type inferred will be + AbstractCollection, as that is a class, whereas Serializable is an interface. +

+ In ambiguous cases, such as when the initializer expression is null, java.lang.Object is inferred. +

+
+
+ +
+
+
+ + + -- cgit