Ruby 1.9中的主要语法更改是什么?

时间:2021-07-13 22:29:24

Also, I'm wondering what effect upgrading to Ruby 1.9 would have on legacy code from version 1.86. Is the new version backwards compatible?

另外,我想知道升级到Ruby 1.9会对版本1.86的遗留代码产生什么影响。新版本是否向后兼容?

3 个解决方案

#1


4  

Sam Ruby has a good slideshow of the major changes: Ruby 1.9: What to Expect

Sam Ruby有一个很好的主要变化幻灯片:Ruby 1.9:期待什么

Just to highlight a few things that could break your code:

只是为了突出一些可能会破坏您的代码的事情:

  • Single character strings
  • 单个字符串

  • {"a", "b"} no longer makes a hash
  • {“a”,“b”}不再生成哈希值

  • Block variables now shadow local variables
  • 块变量现在影响局部变量

#2


4  

I guess that depends on what version you're looking to maintain compatibility with. The CHANGELOG describes the major revisions since the last update including syntax changes, enhancements and bugfixes

我想这取决于你希望保持兼容性的版本。 CHANGELOG描述了自上次更新以来的主要修订,包括语法更改,增强功能和错误修正

#3


4  

Some things are backwards compatible, but many aren't.

有些东西是向后兼容的,但很多东西都没有。

For a near complete overview of all the changes (including examples) in 1.9.x, check out Eigenclass's blog last archive.org snapshot of Eigenclass's blog.

有关1.9.x中所有更改(包括示例)的近乎完整的概述,请查看Eigenclass的博客上一个archive.org的Eigenclass博客快照。

#1


4  

Sam Ruby has a good slideshow of the major changes: Ruby 1.9: What to Expect

Sam Ruby有一个很好的主要变化幻灯片:Ruby 1.9:期待什么

Just to highlight a few things that could break your code:

只是为了突出一些可能会破坏您的代码的事情:

  • Single character strings
  • 单个字符串

  • {"a", "b"} no longer makes a hash
  • {“a”,“b”}不再生成哈希值

  • Block variables now shadow local variables
  • 块变量现在影响局部变量

#2


4  

I guess that depends on what version you're looking to maintain compatibility with. The CHANGELOG describes the major revisions since the last update including syntax changes, enhancements and bugfixes

我想这取决于你希望保持兼容性的版本。 CHANGELOG描述了自上次更新以来的主要修订,包括语法更改,增强功能和错误修正

#3


4  

Some things are backwards compatible, but many aren't.

有些东西是向后兼容的,但很多东西都没有。

For a near complete overview of all the changes (including examples) in 1.9.x, check out Eigenclass's blog last archive.org snapshot of Eigenclass's blog.

有关1.9.x中所有更改(包括示例)的近乎完整的概述,请查看Eigenclass的博客上一个archive.org的Eigenclass博客快照。