at 4:31 PM

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.

<?php
function defaultValueForReturn(){
   return;
}// now i test it
var_dump (defaultValueForReturn());  ?>

And this is result:


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:


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


Tulis Komentar dengan akun Facebook Anda.

0 comments:

Post a Comment