swift学习---长句部分四(第一次计划看一本完整的英文资料,你是最棒的,加油)

1. Mutability of Collections

集合的可变性

2. For dictionaries, immutability  also mean that you cannot  replace the value for an existing  key in the dictionary .

对字典来说,不可变性也意味这我们不能替换其中任何现有键所对应的值。

3. This enables Swift’s array type to provide optimal performance for array  operations when the size an array is fixed.

这使得swift数组在大小被固定的时候依然可以做得很棒。

 

4. The collection of items being iterated is a  closed range of numbers from 1 to 5 inclusive , as indicated  by the use of the closed range operator (…).

例子中用来进行便利的元素是一组使用闭区间操作符()表示从15的闭区间数字。

5. In the example above ,index is a constant whose value is automatically set at the start of each iteration of the loop . As such ,  it does not to be declared before it is used . It is implicitly declared simply by its  inclusion in the loop declaration , without the need for a let declaration keyword.

上面的例子中,index 是一个每次循环便利开始时被自动赋值的常量。这种情况下,index在使用前不需要声明,只需要將它包含在循环的声明中,就可以对其进行隐式声明,而无需使用let关键字声明。

 

6. If you do not need each value from the range ,you can ignore the values by using an underscore in place of a  variable name:

如果你不需要知道范围内每一项的值,你可以使用下划线(-)替代变量名来忽略访对值的访问:

7. retrieve  检索、恢复

8. Semicolons separate the three parts of the loop’s definition, as in C .  however , unlike C ,

Swift  doesn’t  need to parentheses around the entire “initialization ; condition;  increment” block.

Semicolons 分号

Parentheses 园括号

C语言一样,分号將循环的定义分为3个部分,不同的是,Swift不需要使用圆括号將初始条件,条件,增加包括起来。

9. evaluated  评价、评估

 

10. increment expression递增表达式

 

11.This example uses a very simple approach to dice rolling.

本例中使用了最简单的方法来模拟投骰子。

 

combination
[英]ˌkɒmbɪˈneɪʃn[美]ˌkɑ:mbɪˈneɪʃn

permutation
[英]ˌpɜ:mjuˈteɪʃn[美]ˌpɜ:rmjuˈteɪʃn

n.(一组事物可能的一种)序列,排列,排列中的任一组数字或文字

[例句] Each such arrangement is a permutation of the symbols.
每一个这样的摆布都是这些符号的一种排列。

n.结合;联合体;密码组合;连裤内衣

 

Swift  provides two  ways to add conditional branches  to your code,known as  the if statement and switch statement .Typically, you use the if statement to evaluate simple  conditions with only  a few  possible outcomes. The switch statement is

better suited to more complex conditions  with multiple possible  permutations,and is

useful  in situations where pattern-matching can help select an  appropriate code branch to  execute.

Switch 提供两种类型的条件语句:if语句和switch语句。通常,当条件较为简单且可能的情况很少时,使用if语句。而switch语句更适合用于复杂的条件,可能的情况很多且需要用到模式匹配的情景。

scarf[英]skɑ:f[美]skɑ:rf

n.围巾,领巾;嵌接;桌巾,台巾;(木材,金属,皮革的)嵌接
v.围(围巾);打(领带);披(披巾);用围巾[台布]围[盖]

[例句] I make a note to ask him about that scarf.
我给自己写了个提醒卡要问问那条围巾。
 

exclude[英]ɪkˈsklu:d[美]ɪk'sklu:d
vt.排除,不包括;排斥;驱除,赶出

[例句] But for the future we do not exclude any possibility.
但就未来而言,我们不排除任何可能性。
 
compare against 与---做比较
In  its simplest form, a switch statement compares a value against one or more values  of the same type:
switch 语句最简单的形式就是把某个值与一个或者若干个相同类型的值做比较。
 
specify[英]ˈspesɪfaɪ[美]ˈspɛsəˌfaɪ
vt.指定;详述;提出…的条件;使具有特性
vi.明确提出,详细说明
 
Every  switch statement consists of multiple possible cases,each of which begins
with the case keyword. In  addition to comparing against specific values ,Swift provides several  ways  for each case to specify more complex  matching  patterns.
These  options are described later in this section.
switch 语句都由很多个case构成。为了匹配某些更特定的值,Swift提供了更复杂的匹配模式,这些模式將在本节的稍后部分提到。
consonant
consonant[英]ˈkɒnsənənt[美]ˈkɑ:nsənənt
n.辅音,子音;辅音字母
adj.一致的;符合的;协和音的;和音的
 
It is not practical to write all other possible characters as part of  a  switch case,and
so this  switch statement provides  a default  case to match  all other characters that
are not vowels or constants.This provision  ensure that the switch statement is  exhaustive.
exhaustive[英]ɪgˈzɔ:stɪv[美]ɪɡˈzɔstɪv
adj.彻底的,透彻的;消耗的,使枯竭的;详尽的,无遗的;详尽无遗
由于为其他可能的字符写case 快没有实际意义,因此在这个例子中使用了默认快来处理剩下的既不是元音也不是辅音的字符--这就保证了switch语句的完备性。
 
No Implicit Fallthrough
不存在隐式的贯穿
 
 
in contrast with
[英]in ˈkɔntræst wið[美]ɪn ˈkɑntræst wɪð
相比之下
 
break out of[英]breik aut ɔv[美]brek aʊt ʌv
逃出
[例句] First , we must break out of the reagan-era straitjacket concerning taxes and regulation.
首先,我们要打破里根时代关于税收和监管的老观念。
 
  You can still break out of a matched switch case before that case has completede its
execution if you need to.
你依然可以在case快中的代码执行完毕前跳出。
Range Matching
范围匹配
The three switch cases declare placeholder constants x and y ,witch tempotrarily
take on one or both tuple values from anotherPoint.
这三个case都声明了常量x和y的占位符,用于临时获取元组anotherpoint的一个或者两个值。
arbitrary[英]ˈɑ:bɪtrəri[美]ˈɑ:rbətreri
adj.随意的,任性的,随心所欲的;主观的,武断的;霸道的,专制的,专横.
 

 diagonal line 对角线

As in the previous example , the final case matches all possible remaining values. and so a default case is not needed to make the  switch statement exhaustive.

在前面的例子汇总,由于最后一个case块中匹配了余下所有的可能值,switch语句已经完备了,因此不需要书写默认块。

control transfer statements.  条件转移语句

cryptic puzzle phrase 含义模糊的语句

catchall[英]'kætʃɔ:l[美]'kætʃˌɔ:l
n.放各种各样物品的容器,包罗甚广的话(或法律等),装零杂物品的容器
adj.包罗万象的

[例句] Catchall : a receptacle or storage area for odds and ends.
杂物包:盛放杂物和残渣的容器或地方。

 

Labeled  Statement 标签语句

You can nest loops and switch stements inside other loops and switch staement in Swift to create complex control flow structures.

在swift语言中你可在循环体和switch代码快中嵌套使用循环体和switch代码块来创造复杂的控制流结构。

functions are self-contained chunks of code that perform a specific  task.

函数是执行特定任务的代码只包含块。

Strictly speaking, the sayGoodbye  function does still return a value,even  though  no

return value is defined . Function  without a defined return type return a special value of  type Void.

严格来说,sayGoodbye函数确实有一个返回值,即使没有定义返回值。没有定义返回类型的函数返回一个void类型的特殊值。

Founctioon with Multiple Return  Values

多返回值函数

Founction Parameter Names

函数形参

Local parameter name

本地形参名

hash symbol[英]hæʃ ˈsimbəl[美]hæʃ ˈsɪmbəl
n.哈希符(号),井字符(号)

ambiguity
[英]ˌæmbɪˈgju:əti[美]ˌæmbɪˈɡjuɪti

n.含糊;意义不明确;含糊的话,模棱两可的话;可作两种或多种解释

ambiguous[英]æmˈbɪgjuəs[美]æmˈbɪɡjuəs

adj.含糊的,不明确的;引起歧义的;有两种或多种意思的;

The function‘s choice of  parameter makes for  a clear,readable function body,

while also enable tne function to be called without ambiguilty:

该函数对形参名的选择使得函数主体更加清晰易读,并且在调用该函数的时候也不会有歧义:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值