Home News DOC Class DL Others Cooker
Documents  >  Tutorial  >  Return
Return statement

It returns control of execution to the caller of the member.


Table of contents:


Format

return

Expression

Semicolon

Example

Format

The format of the return statement are:


return ;

return expression ;


Member execution is stopped by the return statement. And execution control is returned to the member caller.

If there is an expression after the keyword return, the instance generated by the expression is returned to the caller as a return value. The class of the expression must match the class of the member's return value.

If there is no expression, an instance of the void class is returned.

return

A keyword that indicates that it is a return statement.

Expression

Generates an instance that will be returned to the caller. If there is no return value, it can be omitted.


The class of the returned instance must match the return type of the member.

The return statement must not return a value if the calling member does not return a value or void is specified.

Semicolon

The end of a return statement is represented by a semicolon.

Example

1:

class example

2:

open getter string URL

3:

return "http://example.com/";

4:

eg

5:

ec

1:

example ex;

2:

string url = ex.URL;

Next
Previous
Copyright © Rice All rights reserved.