Skip to content

Commit

Permalink
Chinese translation fix
Browse files Browse the repository at this point in the history
Make some translation easier to understand.The original tanslation really confused me and I want to help to make it easier to understand for the beginner.
  • Loading branch information
moshoujingli committed Oct 17, 2014
1 parent 493a16b commit 2fe4954
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion web/zh_cn/type-basics.textile
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ defined class Chicken
scala> val getTweet: (Bird => String) = // TODO
</pre>

标准动物库有一个函数满足了你的需求,但它的参数是<code>Animal</code>。在大多数情况下,如果你说“我需要一个___,我有一个___的子类”是可以的。但是,在函数参数这里是逆变的。如果你需要一个参数为<code>Bird</code>的函数,并且指向一个参数为<code>Chicken</code>的函数,那么给它传入一个<code>Duck</code>时就会出错。但指向一个参数为<code>Animal</code>的函数就是可以的
标准动物库有一个函数满足了你的需求,但它的参数是<code>Animal</code>。在大多数情况下,如果你说“我需要一个___,我有一个___的子类”是可以的。但是,在函数参数这里是逆变的。如果你需要一个接受参数类型<code>Bird</code>的函数变量,但却将这个变量指向了接受参数类型为<code>Chicken</code>的函数,那么给它传入一个<code>Duck</code>时就会出错。然而,如果将该变量指向一个接受参数类型为<code>Animal</code>的函数就不会有这种问题

<pre>
scala> val getTweet: (Bird => String) = ((a: Animal) => a.sound )
Expand Down

0 comments on commit 2fe4954

Please sign in to comment.