Monday, April 19, 2010

Return type in haXe

We use return keyword to exit from a function. We also return a value from a function with this keyword. The return statement takes the general form:
Return value;
Where value is the value to be returned. Let’s see an example of return keyword.
function func( i : Int ) : Bool {
if( i % 2 != 0 ){
return true;
}
return false;
}
To return a value the above function has the return type Boolean. We write the return type after the function declaration and the type precedes a colon(:). We can use the return statement without assigning a value to it. It causes the function to return immediately, before the function’s closing curly brace is reached. Let’s see another example of it.
function nothing(x:Int) : Void {
if( x==10 ){
return;
}
// ....
}
Here the function has void return type. It checks x’s value against 10 and if it is true then it executes the return statement without any value.
See the book OpenCart 1.4 Template Design Cookbook.
See the book Joomla Mobile Development Beginners Guide




List of my works:

Opencart Extensions:

  1. Product Based Quantity Wise Shipping: Find it here.
  2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
  3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
  4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
  5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
  6. Formcaptcha - add captcha on the register page: Find it here.

My Books:

  1. OpenCart 1.4 Template Design Cookbook.
  2. Joomla Mobile Development Beginners Guide

No comments: