Default value for return
A few days ago, i try to create a code with PHP, with a function i do a return in function with some values and then i got a mystery about default value for return keyword, to get absolutelly value with this keyword i create a function to test it, like this.
function defaultValueForReturn(){
return;
}// now i test it
var_dump (defaultValueForReturn()); ?>
And this is result:
![](http://1.bp.blogspot.com/-7n-ZFEjMZ7s/T15DBKWNWLI/AAAAAAAAAr0/ahiKvksp6Dg/ s320/Screenshot+at+2012-03-13+01:39:29.png)
What about with other programming language such as Python, Javascript, etc.
Check this!
Python.
Code:
#!/usr/bin/env python
def defaultValueForReturn():
return
type(defaultValueForReturn())
Result:
![](http://1.bp.blogspot.com/-MfcGitBsriE/T2dTSGZTphI/AAAAAAAAAsI/CfFQOTuHWsw/ s640/python-default-value.png)
Javascript.
Code:
function returnValue() {
return;
}
var y = returnValue();
console.log(typeof (y));
Result:
undefined
Ruby.
Code:
def defaultValueForReturn()
return
end
y=defaultValueForReturn()
print y.class
Result:
NilClass