Skip to content

Commit 81a366e

Browse files
committed
Translate Ruby 3.4.0 preview2 news (zh_tw)
1 parent 235860a commit 81a366e

File tree

1 file changed

+136
-0
lines changed

1 file changed

+136
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
---
2+
layout: news_post
3+
title: "Ruby 3.4.0 preview2 發布"
4+
author: "naruse"
5+
translator: "Bear Su"
6+
date: 2024-10-07 00:00:00 +0000
7+
lang: zh_tw
8+
---
9+
10+
{% assign release = site.data.releases | where: "version", "3.4.0-preview2" | first %}
11+
我們很高興宣布 Ruby {{ release.version }} 發布了。
12+
13+
## Prism
14+
15+
預設的解析器從 parse.y 切換為 Prism。 [[Feature #20564]]
16+
17+
## 語法變更
18+
19+
* 沒有 `frozen_string_literal` 註解的檔案中的字串文字,現在行為會跟被凍結一樣。如果它們被修改則會發出棄用警告。
20+
這些警告可以透過 `-W:deprecated``Warning[:deprecated] = true` 啟用。
21+
若要停用此變更,您可以在執行 Ruby 時加上參數 `--disable-frozen-string-literal`[[Feature #20205]]
22+
23+
* 新增 `it` 來引用 block 的傳入參數。 [[Feature #18980]]
24+
25+
* 現在呼叫方法支援使用 Keyword splatting `nil`
26+
`**nil` 的處理方式與 `**{}` 類似,不會傳遞 keywords,也不會呼叫任何轉換方法。 [[Bug #20064]]
27+
28+
* Block passing 不再允許作為索引。 [[Bug #19918]]
29+
30+
* 不定長度參數不再允許作為索引。 [[Bug #20218]]
31+
32+
## 核心類別更新
33+
34+
注意:我們只列出特別的類別更新。
35+
36+
* Exception
37+
38+
* Exception#set_backtrace 現在可接受 `Thread::Backtrace::Location` 陣列。
39+
`Kernel#raise``Thread#raise``Fiber#raise` 也接受同樣的新格式。 [[Feature #13557]]
40+
41+
* Range
42+
43+
* Range#size 如果 range 無法迭代的話,現在會拋出 TypeError。 [[Misc #18984]]
44+
45+
## 相容性問題
46+
47+
注意:不包含功能問題的修正。
48+
49+
* 錯誤訊息與 backtrace 的顯示改變。
50+
* 使用單引號 (`'`) 取代反引號 (`` ` ``) 作為起始引號。 [[Feature #16495]]
51+
* 在方法名稱前顯示類別名稱 (僅當類別有固定名稱時)。 [[Feature #19117]]
52+
* `Kernel#caller``Thread::Backtrace::Location` 的方法等等,也做了對應的改變。
53+
54+
```
55+
舊:
56+
test.rb:1:in `foo': undefined method `time' for an instance of Integer
57+
from test.rb:2:in `<main>'
58+
59+
新:
60+
test.rb:1:in 'Object#foo': undefined method 'time' for an instance of Integer
61+
from test.rb:2:in '<main>'
62+
```
63+
64+
* `Hash#inspect` 渲染變更。 [[Bug #20433]]
65+
* Symbol keys 會使用現代 symbol key 語法顯示: `"{user: 1}"`
66+
* 其他 keys 現在會在 `=>` 前後加上空白: `'{"user" => 1}'`,在之前不會添加: `'{"user"=>1}'`
67+
68+
## C API 更新
69+
70+
* `rb_newobj``rb_newobj_of` (和相對應的巨集 `RB_NEWOBJ`, `RB_NEWOBJ_OF`, `NEWOBJ`, `NEWOBJ_OF`) 已經被移除。 [[Feature #20265]]
71+
* 移除已廢棄的函式 `rb_gc_force_recycle`[[Feature #18290]]
72+
73+
## 實作改善
74+
75+
* `Array#each` 用 Ruby 重寫並有更好的效能 [[Feature #20182]]
76+
77+
## 其他變更
78+
79+
* 將 block 傳遞給不使用傳入 block 的方法,會在 verbose 模式 (`-w`) 下顯示警告。
80+
[[Feature #15554]]
81+
82+
* 當重新定義一些由直譯器與 JIT 特別最佳化的核心方法,例如 `String.freeze``Integer#+`,現在會發出效能類型警告 (`-W:performance` or `Warning[:performance] = true`)。
83+
[[Feature #20429]]
84+
85+
請參閱 GitHub 發布如 [Logger](https://github.com/ruby/logger/releases) 和變更紀錄來了解更多關於預設 gems 與 bundled gems 的資訊。
86+
87+
參見 [NEWS](https://github.com/ruby/ruby/blob/{{ release.tag }}/NEWS.md)
88+
[commit logs](https://github.com/ruby/ruby/compare/v3_3_0...{{ release.tag }})
89+
來了解更多。
90+
91+
自 Ruby 3.3.0 以來,計 [{{ release.stats.files_changed }} 檔案變更,{{ release.stats.insertions }} 行新增(+),{{ release.stats.deletions }} 行刪減(-)](https://github.com/ruby/ruby/compare/v3_3_0...{{ release.tag }}#file_bucket)。
92+
93+
94+
## 下載
95+
96+
* <{{ release.url.gz }}>
97+
98+
SIZE: {{ release.size.gz }}
99+
SHA1: {{ release.sha1.gz }}
100+
SHA256: {{ release.sha256.gz }}
101+
SHA512: {{ release.sha512.gz }}
102+
103+
* <{{ release.url.xz }}>
104+
105+
SIZE: {{ release.size.xz }}
106+
SHA1: {{ release.sha1.xz }}
107+
SHA256: {{ release.sha256.xz }}
108+
SHA512: {{ release.sha512.xz }}
109+
110+
* <{{ release.url.zip }}>
111+
112+
SIZE: {{ release.size.zip }}
113+
SHA1: {{ release.sha1.zip }}
114+
SHA256: {{ release.sha256.zip }}
115+
SHA512: {{ release.sha512.zip }}
116+
117+
## Ruby 是什麼
118+
119+
Ruby 最初由 Matz(Yukihiro Matsumoto)於 1993 年開發的開源軟體。可以在許多平台上執行。使用者來自世界各地,特別活躍於網路開發領域。
120+
121+
[Feature #13557]: https://bugs.ruby-lang.org/issues/13557
122+
[Feature #15554]: https://bugs.ruby-lang.org/issues/15554
123+
[Feature #16495]: https://bugs.ruby-lang.org/issues/16495
124+
[Feature #18290]: https://bugs.ruby-lang.org/issues/18290
125+
[Feature #18980]: https://bugs.ruby-lang.org/issues/18980
126+
[Misc #18984]: https://bugs.ruby-lang.org/issues/18984
127+
[Feature #19117]: https://bugs.ruby-lang.org/issues/19117
128+
[Bug #19918]: https://bugs.ruby-lang.org/issues/19918
129+
[Bug #20064]: https://bugs.ruby-lang.org/issues/20064
130+
[Feature #20182]: https://bugs.ruby-lang.org/issues/20182
131+
[Feature #20205]: https://bugs.ruby-lang.org/issues/20205
132+
[Bug #20218]: https://bugs.ruby-lang.org/issues/20218
133+
[Feature #20265]: https://bugs.ruby-lang.org/issues/20265
134+
[Feature #20429]: https://bugs.ruby-lang.org/issues/20429
135+
[Feature #20564]: https://bugs.ruby-lang.org/issues/20564
136+
[Bug #20433]: https://bugs.ruby-lang.org/issues/20433

0 commit comments

Comments
 (0)