By putting it in a function bug if I find a bug and I change my program I can just run the function again.
把我输入的值放到一个函数里,如果以后我在程序中发现了一个,并对程序进行更改的话,我可以直接。
I, like, caught this big travel bug, and I want to venture out, so that, and
我,就是想旅行,想探险,所以,
And in the process of tidying it up and making it prettier, I'll often by accident find the bug.
让我的程序更漂亮些,在这个清理美化代码的过程中,我常常无意中发现我的错误。
All right, so there's a bug.
好的,这里有一个缺陷。
Oh, no. Oh, wait. Actually, yes. I bought a painting of a bug, a grasshopper
没有,哦,等等。实际上买过。我买过一幅画着虫子、蝗虫之类的东西的画,
bug It's not true now. If there is a bug in the program it's there for only one reason.
如果程序中有一个,那一定是有原因的,是你通过例如犯了。
So something has happened there that wasn't what I expected. Who wants to tell me what that bug is? Yeah?
我已经知道哪一句声明出问题了,一些和我预期不同的事情发生了,有人能告诉我bug在哪儿么?
bug What I typically do is I start with the input that provoked the problem, and I keep making it smaller and smaller.
我这里做的就是从引起,出现的输入开始,然后将输入,一步步的缩小规模。
bug This is an easy bug to come up with. But imagine, if you don't do the test, you're going to get answers that don't make any sense.
这是一个容易发现的,但是想象下,如果你没做测试的话,你会得到没有意义的答案,实际上。
All right. What do you do when you've found the bug and you need to fix it?
好了,当你发现错误并修改它们的时候,你该怎么做?记住一个古老的法则?
bug And maybe by understanding why it worked on a and not on b, you'll get a lot of insight that you won't if you just focus on the bug.
发现很多东西,而你只关注,本身的话就发现不了这么多东西,如果知道你的程序至少还对。
And that does two things: bug one, it helps catch bugs in your code, and secondly it often converts it into a more efficient sequence of instructions before you actually go off and run it. All right?
这有两点好处:,第一是可以帮助你发现程序中的,第二是把你的代码,在运行之前,转换为更有效率的指令的集合,对不对?
bug So now I've narrowed the bug down to one place.
现在我已经把。
Initialization. A very common bug is to initialize a variable. Go through a loop, and then forget to reinitialize it when it needs to be reinitialized again.
忘记初始化,忘记初始化变量是一个很常见的错误,运行完一个循环之后,当需要再次初始化时。
bug If you find a bug, it probably means there bug are more of them. So you ought to be bug a little bit careful. The story I've heard told is you're at somebody's house for dinner, and you're sitting at the dining room table, then you hear a .
对不对?你得修复这个,如果你发现了一个,可能就意味着还有更多的,因此你应该小心点,我听说的一个故事,是当你在别人家吃饭的时候,你坐在餐桌上呢,然后听到了邦的一声响。
So I've got one more piece of bad code on this point and this is buggy five dot c. So as a comment on top bug of this file challenges, what is, in fact, the bug.
所以我在这里得到了一块很烂的代码,这个是buggy5,c,所以作为这个文件顶端的注释,那实际上是那个。
People can get hung up on sort of hunting these things down, and stamping them out, one at a time. And it's a little bit like playing Whack-a-Mole. Right?
我们可能会一次一个的去发现,这个bug并且消灭它,这有点像打鼹鼠对不对?,不停的有鼹鼠跳起来?
And the bug was in my thinking, I did not look for all of the tests.
当然我已经知道这个bug了,就没去做所有的测试。
F-O-O in lowercase and, in fact, foo it is buggy because I typed lowercase F-O-O and FOO yet I get back capital F-O-O as both the original and the copy and that's simply because I haven't done this correctly.
小写的f-o-o,实际上,它是有bug的,因为我输入小写的,而我得到的原始的和拷贝的都是大写的,简单说,我处理错了。
This was one of the very first recorded bugs in the history of computation.
在关于计算的历史上,有一个最早记录的bug,如果你们。
It tells me it is a palindrome. Well, it isn't really.
这就不对了,有bug出现了。
So, all that talking on the bus, and the way they're moving their hands, the bug, that's all where this language is rising from.
因此,那些公交车上的谈话,和他们的手舞足蹈,他们的疯狂,都是语言的来源。
And you'll see at the bottom, bug it says the first actual case of a bug being found.
然后程序就正常工作了,因此这就是第一个被发现的。
应用推荐