Looks like JavaScript, feels like Ruby, and it is a script language fitting in C programmers.
This project is maintained by Kray-G
return
statement is used for returning back from a function.
function func() {
return 10;
}
return
statement can have any expression and returning the evaluated value to caller function.
If there is no expression, null
will be returned Implicitly.
function func1() {
return 10 + funcX(); // if funcX() returns 5, then func1() returns 15.
}
function func2() {
return; // same as `return null`.
}
return
statement can have if-modifier
.
See the example below.
return 10 if (a < 10); // return 10 if `a` is less than 10.
return if (b < 10); // return null if `b` is less than 10.
function func() {
return 10;
}
System.println(func());
10
function func() {
return;
}
System.println(func().isUndefined ? "null" : "defined");
null
function func(a) {
return if (a < 10);
return a * 20;
}
System.println((a = func( 8)).isUndefined ? "null" : a);
System.println((a = func( 9)).isUndefined ? "null" : a);
System.println((a = func(10)).isUndefined ? "null" : a);
null
null
200
function func(a) {
return a * 20 if (a < 10);
return;
}
System.println((a = func( 8)).isUndefined ? "null" : a);
System.println((a = func( 9)).isUndefined ? "null" : a);
System.println((a = func(10)).isUndefined ? "null" : a);
160
180
null