Skip to content

Commit 88368bb

Browse files
authored
Translate Ruby 3.4.0 preview1 news (zh_tw) (#3244)
1 parent dd11d25 commit 88368bb

File tree

1 file changed

+126
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)