So something has happened there that wasn't what I expected. Who wants to tell me what that bug is? Yeah?
我已经知道哪一句声明出问题了,一些和我预期不同的事情发生了,有人能告诉我bug在哪儿么?
Well some things I can actually expect may happen and I want to handle them.
我能预期的一些事情可能会发生,我希望能处理他们。
Then, once we did that we could plug that into the formula that I gave you last time and get the standard deviation of the portfolio and the expected return on the portfolio.
再将估算出的数值代入到,上节课给你们的公式中,就能得到资产投资组合的标准差,和该投资组合的预期收益率
Yeah, so maybe even among your roommates, maybe you don't need a contract because you can manage to achieve the same ends, by the fact that you're going to be interacting with the same person, over and over again during your time at Yale.
没错,就算你和室友没有书面协议,你们一样能达到预期的目的,因为在耶鲁大学上学期间,你们总要碰面
So the exceptions are useful when you want to have the ability to say, I expect in general this kind of behavior, but I do know there are some other things that might happen and here's what I'd like to do in each one of those cases. But I do want to make sure that I don't let a value that I'm not expecting pass through.
所以当你希望有能力说,我希望一般是这样的行为,异常是很有用的,但是我明白还有一些其它的情况可能发生,我希望对每一种情况都这么做,但是我跟希望能保证,没有让一个预期之外的情况漏过去。
So, the optimal thing to do if you live in a world like this n is to get n as large possible and you can reduce the standard deviation of the portfolio very much and there's no cost in terms of expected return.
如果现实中也这样简单的话,那么你就尽量增大,这样就能让投资组合的标准差,就会大大降低,从预期收益率的角度来看,这样做的成本是零。
So, summarizing better, assert is something you put in to say to the user, make sure you're giving me input of this type, but I'm going to guarantee you the rest of the code works correctly. Exceptions and exception handlers are saying, here are the odd cases that I might see and here's what I'd like to do in those cases in order to try and be able to deal with them.
所以更好的总结下,断言就是你放在那里告诉用户,保证你输入的是这种类型的,但我能保证剩下的代码运行正确,异常和异常处理做的事,这里有些我能预期的异常情况,并且这里有些情况,我能尝试处理。
应用推荐