summaryrefslogtreecommitdiffstats
path: root/tutorial/tutorial2.html
diff options
context:
space:
mode:
authorchiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>2003-05-16 17:07:03 +0000
committerchiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>2003-05-16 17:07:03 +0000
commit5fc3a4c6aa6cd5378d417f98b66f76529c4341e4 (patch)
treed86a6647b4af2691d80ed2334737ab2a88c6f781 /tutorial/tutorial2.html
parent51df92b44b8e1dcbcdb75e1390a81c0aa2f9ae78 (diff)
downloadjavassist-5fc3a4c6aa6cd5378d417f98b66f76529c4341e4.tar.gz
javassist-5fc3a4c6aa6cd5378d417f98b66f76529c4341e4.zip
modified the semantics of ($r).
git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@16 30ef5769-5b8d-40dd-aea6-55b5d6557bb3
Diffstat (limited to 'tutorial/tutorial2.html')
-rw-r--r--tutorial/tutorial2.html19
1 files changed, 16 insertions, 3 deletions
diff --git a/tutorial/tutorial2.html b/tutorial/tutorial2.html
index 62c26a94..b9ca5bed 100644
--- a/tutorial/tutorial2.html
+++ b/tutorial/tutorial2.html
@@ -350,15 +350,28 @@ For example, this is a typical use:
$_ = ($r)result;</pre></ul>
<p>If the result type is a primitive type, then <code>($r)</code>
-converts from the wrapper type to the primitive type.
+follows special semantics. First, if the operand type of the cast
+expression is a primitive type, <code>($r)</code> works as a normal
+cast operator to the result type.
+On the other hand, if the operand type is a wrapper type,
+<code>($r)</code> converts from the wrapper type to the result type.
For example, if the result type is <code>int</code>, then
<code>($r)</code> converts from <code>java.lang.Integer</code> to
<code>int</code>.
<p>If the result type is <code>void</code>, then
<code>($r)</code> does not convert a type; it does nothing.
-Moreover, the soruce text can include a <code>return</code>
-statement with a resulting value:
+However, if the operand is a call to a <code>void</code> method,
+then <code>($r)</code> results in <code>null</code>. For example,
+
+<ul><pre>$_ = ($r)foo();</pre></ul>
+
+<p>is a valid statement if the result type is <code>void</code>.
+Here, <code>foo()</code> is a <code>void</code> method.
+
+<p>The cast operator <code>($r)</code> is also useful in a
+<code>return</code> statement. Even if the result type is
+<code>void</code>, the following <code>return</code> statement is valid:
<ul><pre>return ($r)result;</pre></ul>