But it's a valuable thing. It says, in each case, I return some useful value from this procedure.
但是这就是变量,是在每个例子中,我从这个程序中返回了一些有用的值。
I can use that to return values, which I can then use elsewhere, which I did-- and if I just come back and highlight this-- inside of that computation.
我可以用它来返回值,然后我可以在别的地方使用这些返回值,正是我做的--如果我回过头来,在高亮一下这个--在这部分计算内部。
And actually, if I don't want to clobber, as we say, overwrite the value of my variable, ; I could declare another one and store the return value in Y; Y so now I have two ints in memory; X and Y, 3 one with two, one with three.
实际上,如果你不想彻底清除,像我们说的,覆盖那个变量的值,我可以申明另一个变量Y,并在Y中保存那个返回值;,现在内存中有两个int数,X和,一个的值为2,一个为。
p1 But if I say, are p 1 and p 2 the same point, it says yes.
和p2是不是同一个点,It,says,no。,返回的结果是肯定的,在这里我有个要强调的点,这个例子里发生的是。
In either event, if I'm looking at the last element, I return.
在这两种情况中,如果是最后一个,元素的话我就返回。
Now let me spend just a second to say, what was this actually doing?
如果我在这里这么做-啊,它返回给我了值?
So I can return true here.
所以我可以在这儿返回真值。
It says, if I want to print out something I built in Cartesian form up here, says, again, I'm going to pass it in a pointer to the instance, that self thing, and then I'm going to return a string that I combine together with an open self and close paren, a comma in the middle, and getting the x-value and the y-value and converting them into strings before I put the whole thing together.
这不仅仅是个列表,它是怎么来做的?,流程是:如果我想要返回,一些已经在笛卡尔模式下建好的值,好,再说一遍,我首先要传入一个,指向实例的指针,也就是,然后我会返回一个,由开括号,闭括号,中间的一个逗号,以及提前转换为字符串格式的。
And I think in the polar one I said, if, what did I do there, I said, yeah, again if the x and y are greater than the other one, I'm going to return them to it.
然后我要返回一些值,我认为在极坐标的形式下我说过,如果,我在这里做了什么来着,我说过,对,再说一次,如果x和y坐标。
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 the question was, why is this return down at this level, it says, well if I ever execute out of this FOR loop, I get to the end of the FOR loop without hitting that branch that took me through the return, then and only then do I want to actually say, gee, I got to this place, there isn't any value to return, none I'm going to return none and none.
问题是,为什么它是在这个级别上返回值呢,意思就是如果我出了这个for循环,就意味着我运行的过程中没有走到任何,带return的支路上去,这时也只有这时我才能说天呐,我终于走到这儿了,这时不会返回任何值,只会返回none和。
Instead I'm going to be expecting the address of some int and the address of another int and thanks to this address I can literally find this address in RAM, do anything I want there, -- return and what I've just done is actually changed or mutate the values of those original variables.
我们所期望的是int型地址,和另外一个int型地址,幸亏这个地址,我可以找在RAM中找到它的地址,然后做我想做的事情,返回我处理后的东西,我可能改变了这些源变量。
应用推荐