From 5fc3a4c6aa6cd5378d417f98b66f76529c4341e4 Mon Sep 17 00:00:00 2001 From: chiba Date: Fri, 16 May 2003 17:07:03 +0000 Subject: modified the semantics of ($r). git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@16 30ef5769-5b8d-40dd-aea6-55b5d6557bb3 --- tutorial/tutorial2.html | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'tutorial/tutorial2.html') 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;

If the result type is a primitive type, then ($r) -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, ($r) works as a normal +cast operator to the result type. +On the other hand, if the operand type is a wrapper type, +($r) converts from the wrapper type to the result type. For example, if the result type is int, then ($r) converts from java.lang.Integer to int.

If the result type is void, then ($r) does not convert a type; it does nothing. -Moreover, the soruce text can include a return -statement with a resulting value: +However, if the operand is a call to a void method, +then ($r) results in null. For example, + +

+ +

is a valid statement if the result type is void. +Here, foo() is a void method. + +

The cast operator ($r) is also useful in a +return statement. Even if the result type is +void, the following return statement is valid:

-- cgit v1.2.3