aboutsummaryrefslogtreecommitdiff
path: root/website/templates/features/var.html
diff options
context:
space:
mode:
Diffstat (limited to 'website/templates/features/var.html')
-rw-r--r--website/templates/features/var.html27
1 files changed, 27 insertions, 0 deletions
diff --git a/website/templates/features/var.html b/website/templates/features/var.html
new file mode 100644
index 00000000..60e24914
--- /dev/null
+++ b/website/templates/features/var.html
@@ -0,0 +1,27 @@
+<#import "_features.html" as f>
+
+<@f.scaffold title="var" logline="Mutably! Hassle-free local variables.">
+ <@f.history>
+ <p><ul>
+ <li><code>var</code> was promoted to the main package in lombok 2.0.0; given that <a href="http://openjdk.java.net/jeps/286">JEP 286</a> establishes expectations, and lombok's take on <code>var</code> follows these, we've decided to promote <code>var</code> eventhough the feature remains controversial.</li>
+ <li><code>var</code> was introduced in lombok 1.16.12 as experimental feature.</li>
+ </ul></p>
+ </@f.history>
+
+ <@f.overview>
+ <p>
+ <code>var</code> works exactly like <a href="/features/val"><code>val</code></a>, except the local variable is <em>not</em> marked as <code>final</code>.
+ </p><p>
+ The type is still entirely derived from the mandatory initializer expression, and any further assignments, while now legal (because the variable is no longer <code>final</code>), aren't looked at to determine the appropriate type.<br />
+ For example, <code>var x = "Hello"; x = Color.RED;</code> does <em>not</em> work; the type of x will be inferred to be <code>java.lang.String</code> and thus, the <code>x = Color.RED</code> assignment will fail. If the type of <code>x</code> was inferred to be <code>java.lang.Object</code> this code would have compiled, but that's not how<code>var</code> works.
+ </p>
+ </@f.overview>
+
+ <@f.confKeys>
+ <dt>
+ <code>lombok.var.flagUsage</code> = [<code>warning</code> | <code>error</code>] (default: not set)
+ </dt><dd>
+ Lombok will flag any usage of <code>var</code> as a warning or error if configured.
+ </dd>
+ </@f.confKeys>
+</@f.scaffold>