Hello sir , good video . On the late part of the video , i do understand that you print(a) and it prints "1" because its the value returned by the function . But i dont understands why it prints 27 when you are not actually executing the function my_func at any stage of the function _ready (you only name it as a variable "a" )
does specifying return types or parameter types just for safe practice? or does it improve performance as well? i never specify in my functions and so far, everything runs ok. Should I start doing so in the future tho?
The warnings it gives can help you avoid mistakes while writing code, and that's about all it does. Makes sure you are passing/receiving the right type of values to prevent bugs. So no, absolutely not necessary to use, but depending on scale and complexity of your project it can help to avoid issues.
@@iaknihs Awesome! i'm kinda confident with not specifying types, so i think i'll stick with my lazy coding ways for now and I think runtime errors will still catch it anyway. Thanks a ton!
Return ends a function, 'returning' to whichever code first called it. Return can optionally also take a value which can then be used in the code we return to.
@@AbdouMadjidi_. It continues the code that was already waiting for what's basically it's reply: say we have a function func add(a, b): return a+b and then we execute this code: # do something first add(3,7) # do something last then our "# do something last" line will only be executed after the add function we created returns it's value (in this case 10). The lower code basically waits for the function to finish doing whatever it does, and then continues when it 'returns'. if a function reaches it's end without the keyword "return" being written anywhere, it will automatically return without a value. so: func do_nothing(): pass is equivalent to func do_nothing(): pass return
@@AbdouMadjidi_. it's given to wherever you return to. If you say: func add(a, b): return a+b var result = add(3, 7) print( result ) then you call function add with parameters 3 and 7, this function does whatever it does, and returns (gives back) the result of 10. you can then ignore the result, or like in this example put it into a variable, print it, or whatever else you want to do with it
little too fast, I can't understand relationships between properties inside those functions, and you just skip over and go onto next thing. You might as well just talk in chinese. I'm gonna go read some manual or find other video.