How is returning the output of a function different from printing it?

后端 未结 7 1706
死守一世寂寞
死守一世寂寞 2020-11-21 11:23

In my previous question, Andrew Jaffe writes:

In addition to all of the other hints and tips, I think you\'re missing something crucial: your functio

相关标签:
7条回答
  • 2020-11-21 12:21

    I think you're confused because you're running from the REPL, which automatically prints out the value returned when you call a function. In that case, you do get identical output whether you have a function that creates a value, prints it, and throws it away, or you have a function that creates a value and returns it, letting the REPL print it.

    However, these are very much not the same thing, as you will realize when you call autoparts with another function that wants to do something with the value that autoparts creates.

    0 讨论(0)
提交回复
热议问题