So there's a return branch on every possible path through the code. And that's valuable, it's something you want to think about as your right your own.
所以代码中每条可能的路径,都会有一个返回值分支,这是非常有价值的,当你自己写程序的时候也应该考虑这件事。
So the first thing it does, price=0 is it says, if self dot price is 0, I'm just going to return.
所以它做的第一件事就是,如果self。,我就返回。
So now let me actually reverse this and go back to the beginning.
所以现在让我们真正倒退,返回到开头。
so, we did get it back to the starting position.
所以,我们让它返回起始位置。
So I want to go back again, now we're considering the line on the board as being flavor in beer, or location in a town, and I want to go back to politics now and go back to the interpretation we started with, so that left and right will end up being left-wing politics versus right-wing politics.
所以我想返回去,现在我们将黑板上的线看成,啤酒的口味或城市的位置,我现在再回去讨论政治,回去解释我们最初,把线的左边和右边,看成左派和右派的原因
So I can return true here.
所以我可以在这儿返回真值。
So, I just return 1.
所以,我只是返回。
Y He's not returning A or B or temp, and definitely not X or Y; so he just did all of this work and yet that's it.
他不会返回A或B或temp,肯定也不是X或;,所以他刚才做了所有的工作,就是那样。
All right? So if I called sqrt alone, that return test value is done, but in this case I bound it to test, so I can go look at test, and there it is.
执行完返回值语句,但是在这里我将把它赋值给,所以当我看test的值的时候就是返回的值。
So this function increment takes nothing, returns nothing, and yet it does something.
所以increment函数不带入参,也不返回值,它也没做什么。
So I might as well return the without i value I just computed.
所以我不妨返回除去i外,我刚算过的值。
That expression, or that value, or that value, literally gets passed back out of that local environment to the value that comes back out of it. So in particular, none none what's solved returns is a pair.
这个表达或者说值,实际上是从那个局部环境中,输出来付给它的,所以solved返回的是一对值,它可以是一对。
Now, the one that we're most interested in ANS is the one where, in fact, it gets out ANS, so you see down here in the code, there's a spot where it's going to return the value of ANS, which is what we want, right? That's the thing that holds the value that we intended to have.
现在我们最感兴趣的是这个,事实上它返回的是,所以你看这段代码,在这里返回ANS值,也就是我们想要的,对吧?,它就承载了我们想得到的值。
So to store in n whatever GetInt returns.
所以存储在n中的是GetInt,的返回值。
So what's going to happen here? If I'm inside this FOR, OK, and I'm running around, if I ever hit a place where this test is true, I'm going to execute that return, return that return returns from the entire procedure. OK? So the return comes back from the procedure.
那么这里发生了什么呢?,如果我是在这个for循环里面,我正在运行,如果我运行到test的值为真的地方,我就会执行,这个return将会返回整个程序的值,明白了吗?所以它将会从整个程序中返回值。
I mean what if you're running so many things, what if the user has copied and pasted their thesis and just pasted it at the blinking prompt such that you're now out of memory because your computer is somewhat limited in memory so get string cannot possibly return all those characters or fit all of those characters in memory and return to you the address of the first.
如果你运行了很多程序,假使用户复制粘贴了他们的论文,只是粘贴在光标提示符那里,这样就出现了内存不足,因为你们的计算机的内存是有限的,所以GetString不可能返回所有的字符,或者保存这些字符到内存中,并且返回第一个字符的地址。
And conceptually, the idea of cubing a value feels like you could package that up into a little box, a little tool that takes input, a value, and returns output the answer A* so you don't have to constantly do A star, A*A So this program ,at the end of today, is pretty much the same thing.
概念上,算一个值的立方就像是,你可以把一个值打包放在一个小盒子里,一个用来接收输入的工具,一个值,然后返回一个答案,所以你并不需要一直使用,等等。,A,star,,A,,and,so,forth。,这个程序,最后,是一个差不多的东西。
应用推荐