diff options
author | Reinier Zwitserloot <reinier@zwitserloot.com> | 2017-05-08 21:28:02 +0200 |
---|---|---|
committer | Reinier Zwitserloot <reinier@zwitserloot.com> | 2017-05-29 21:02:54 +0200 |
commit | 8b7a7cbc813653a3248d6cf3a7779e220957bc85 (patch) | |
tree | b9acfb9d68c6866acc3cfb9ee59d72ff43f1ebc3 /website-old/features/val.html | |
parent | 72fd50b9f1db1ab6bfc1753ba6a1e686a2f0f22c (diff) | |
download | lombok-8b7a7cbc813653a3248d6cf3a7779e220957bc85.tar.gz lombok-8b7a7cbc813653a3248d6cf3a7779e220957bc85.tar.bz2 lombok-8b7a7cbc813653a3248d6cf3a7779e220957bc85.zip |
The great rename: the old ‘website’ is now ‘website-old’, and ‘website2’ is now ‘website’.
Diffstat (limited to 'website-old/features/val.html')
-rw-r--r-- | website-old/features/val.html | 76 |
1 files changed, 76 insertions, 0 deletions
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 @@ +<!DOCTYPE html> +<html><head> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> + <link rel="stylesheet" type="text/css" href="../logi/reset.css" /> + <link rel="stylesheet" type="text/css" href="features.css" /> + <link rel="shortcut icon" href="../favicon.ico" type="image/x-icon" /> + <meta name="description" content="Spice up your java" /> + <title>val</title> +</head><body><div id="pepper"> + <div class="minimumHeight"></div> + <div class="meat"> + <div class="header"><a href="../index.html">Project Lombok</a></div> + <h1>val</h1> + <div class="byline">Finally! Hassle-free final local variables.</div> + <div class="overview"> + <h3>Overview</h3> + <p> + <em>NEW in Lombok 0.10: </em>You can use <code>val</code> 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. + </p><p> + <code>val</code> is actually a 'type' of sorts, and exists as a real class in the <code>lombok</code> package. You must import it for val to work (or use <code>lombok.val</code> as the type). + The existence of this type on a local variable declaration triggers both the adding of the <code>final</code> keyword as well as copying the type of the initializing expression which overwrites + the 'fake' <code>val</code> type. + </p><p> + <em>WARNING: This feature does not currently work in NetBeans. We're working on fixing that.</em> + </p> + </div> + <div class="snippets"> + <div class="pre"> + <h3>With Lombok</h3> + <div class="snippet">@HTML_PRE@</div> + </div> + <div class="sep"></div> + <div class="post"> + <h3>Vanilla Java</h3> + <div class="snippet">@HTML_POST@</div> + </div> + </div> + <div style="clear: left;"></div> + <div class="overview confKeys"> + <h3>Supported configuration keys:</h3> + <dl> + <dt><code>lombok.val.flagUsage</code> = [<code>warning</code> | <code>error</code>] (default: not set)</dt> + <dd>Lombok will flag any usage of <code>val</code> as a warning or error if configured.</dd> + </dl> + </div> + <div class="overview"> + <h3>Small print</h3><div class="smallprint"> + <p> + For compound types, the most common superclass is inferred, not any shared interfaces. For example, <code>bool ? new HashSet() : new ArrayList()</code> + is an expression with a compound type: The result is both <code>AbstractCollection</code> as well as <code>Serializable</code>. The type inferred will be + <code>AbstractCollection</code>, as that is a class, whereas <code>Serializable</code> is an interface. + </p><p> + In ambiguous cases, such as when the initializer expression is <code>null</code>, <code>java.lang.Object</code> is inferred. + </p> + </div> + </div> + <div class="footer"> + <a href="index.html">Back to features</a> | <span class="disabled">Previous feature</span> | <a href="NonNull.html">Next feature (@NonNull)</a><br /> + <a href="../credits.html" class="creditsLink">credits</a> | <span class="copyright">Copyright © 2009-2016 The Project Lombok Authors, licensed under the <a href="http://www.opensource.org/licenses/mit-license.php">MIT license</a>.</span> + </div> + <div style="clear: both;"></div> + </div> +</div> +<script type="text/javascript"> + var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); + document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E")); +</script> +<script type="text/javascript"> + try { + var pageTracker = _gat._getTracker("UA-9884254-1"); + pageTracker._trackPageview(); + } catch(err) {} +</script> +</body></html> |