Can any explain about objects like integers created on the fly? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Can any explain about objects like integers created on the fly?

Creating a function normally (using def) assigns it to a variable automatically. This is different from the creation of other objects - such as strings and integers - which can be created on the fly, without assigning them to a variable.

13th Nov 2017, 7:42 AM
Abin Singh R
Abin Singh R - avatar
2 Answers
+ 8
I don't know if it's what you mean, but method definition automatically assigns a name to it (unless it is a lambda, which is an anonymous function). You can then call it, with parameters or without, whether it returns some value or not. On the other hand, objects like integers or strings may not necessarily be glued to a variable. print("Hello world") will just print out the greeting. The print() method will be called, the "Hello world" string will be passed as argument/parameter, but it will not be assigned to any variable. That what you meant?
13th Nov 2017, 7:54 AM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
0
Yes now i am cleared.. thanks kuba
13th Nov 2017, 8:10 AM
Abin Singh R
Abin Singh R - avatar