I've written a little for loop, which is going to iterate over all of the elements in the list.
让我们先看看这儿的代码,我已经写了一个循环语句,用来迭代处理数组中所有的元素。
You can say if this is true, then go and do the following pieces of code or puzzle pieces that are inside this part of the block, else go ahead and do these that are down here.
你可以说如果条件成立,执行下面的代码段,或板块中的拼图,否则跳过去执行这下面的语句。
You've read the short article he has in the Jewish Study Bible, but he's also written about this at great length in other places.
你们已经读到过他在《犹太读经》里的短文,在其他的地方他也写过这些伟大的语句。
So far, we have the following in our language. Right, we have assignment.
至今为止,我们已经学习了,该语言的以下内容,我们学习了赋值语句。
His language is a sort of mishmash of poorly used academic locutions: "worklife plans." It sounds almost like corporate speak, in a way.
他的语言是一种用得很不好的学术语句的混杂:,职业生涯计划,听起来就像是电脑在说话一样不自然。
It didn't really crash, it found an assert statement. So if you look at the bottom of the function, you'll see that, in fact, I checked for that.
其实程序并没崩溃,它只是碰到一个断言语句然后停了下来,如果你看看函数的顶部,你会看到,实际上我断定计数器。
Right. So similarly, if you've got one line of code with a semicolon at the end saying, this is the end of the statement, it doesn't really make sense to continue that conversation to try to continue conceptually that puzzle piece with curly braces.
对的,类似的,如果你得到了一行代码,后面有一个分号,标志语句的结尾,这就没有意义来继续,那个会话来尝试对那段代码,使用花括号。
But the string, the sentence or the words that we're displaying on the screen, previously you clicked on a little white text field and typed it in, well now you're gonna do the same thing at the keyboard but you're gonna have to sandwich it in between double quotation marks.
这些你想输出到屏幕上的字符串啊,语句啊,单词啊,或者你事先,在白色输入框中敲进去的内容,现在你们需要用键盘做同样的事情,但是你们要写在,双引号之间。
Step 5, now this is an example of what we'll henceforth call a condition or a branch because it's sort of a fork in the road.
步骤五,这是一个关于我们调用一个条件,或者分支语句的例子,因为这是一个岔路口。
Computers generally have things called--computer languages generally have things called "statements".
计算机语言,有一种叫做,“语句“的东西。
Well, the beauty is in this simple stupid little statement of the obvious.
关键的一点就是这个看似,有点愚蠢的语句。
So what we've seen is I've run it twice here.
我们现在看到的就是,我执行了这条打印语句两次。
First one, when I write a piece of code, especially code that has branches in it, when I design test cases for that piece of code, I should try and have a specific test case for each possible path through the code.
第一点,当我们写代码的时候,尤其是一些含有分支语句的代码的时候,当我为这些代码,设计测试用例的时候,我应该为每一个可能的程序路径,都设计一个特别的用例。
So you might have chosen a different sentence or whatnot, but that's fine.
所以你们可能选择了一个不同的语句,或其它的东西,但是那挺好的。
This is the first of the conditionals that we're going to see.
这是我们会学到的,第一个条件语句。
Since I'm not sure I won't need to go back to it.
我注释掉了之前的调试语句。
I get the int and store it in n. The switch statement takes inside its parenthesis an int or a char or some primitive type.
我得到一个整数并把它存储,到n中,switch语句的圆括号里可以是一个整数,或者一个字符或其他的基本类型。
The semicolon just separates this from the rest.
其中的分号只是用来间隔两条语句。
So while. And thankfully the jargon that the authors of this language chose early on conjures up the right ideas in your mind while something is true.
即while语句,幸好该语言的创始人,选择的术语都很通俗易懂,让人只通过字面意思就能联想到其真正含义。
For now the way to think about this is, cp2 when I call that class definition, it goes off and allocates a specific spot in memory that corresponds to that instance.
这个语句所做的,就是建立了,这个类型的实例cp1和,这个类型的特定版本,现在你们可以这么认为。
So we've seen a lot of this, for instance, in office hours and maybe you too have done or are currently doing this, but there's a problem with writing a statement, like print F, followed by, get int, alone.
我们看过很多这个,例如,在办公时间,可能你们做完了或还在做这个,但是写语句的时候有个问题,就像printf,紧跟着的是GetInt,单独的。
So really, the rule of thumb if you think back to Scratch is -- that any time you write a statement -- -- something that does something in one line of code -- you generally need the semicolon there.
实际上,根据经验,你们回忆一下在Scratch中,任何时候你们写一条语句-,处理一些操作的一行代码-,你们通常需要在那里加个分号。
So don't underestimate the value for the next week or two of just inserting printf statements into your code temporarily just to print out what the value of some variable is, or some expression is, so that you can just do a sanity check.
所以不要低估下一两周的重要性,虽然我们只将“printf“语句暂时地植入到,我们的代码中,只是用来打印一些,变量或表达式的值,所以你们提醒一下自己。
Here, print F, recalls a statement and just like in scratch, statements were these one-liners.
这里,printf,召回了一个语句,像在scratch中,语句是这些单行方式的。
So a loop or an infinite loop, because true is always true, there is no-- nothing on the screen that seems to change this keyword true, so this is actually a deliberate infinite loop, but so was that thing up top to forever say hi or whatever it is you wanted to do.
因此而出现死循环,屏幕上的这些语句无论怎么运行,都无法改变它为真的事实,这就是所谓的死循环,无论你想不想要,屏幕上都会不断打印出“hi“
And another one might be "play sound meow."
其他的语句可能是“play,sound,meow,“
应用推荐