gpt4 book ai didi

ruby - 为什么是 "wrong to require rubygems"?

转载 作者:数据小太阳 更新时间:2023-10-29 06:48:26 25 4
gpt4 key购买 nike

根据 this post ,需要 ruby​​gems 是一种反模式。

require 'rubygems'

争论似乎归结为:

When I use your library, deploy your app, or run your tests I may not want to use rubygems. When you require 'rubygems' in your code, you remove my ability to make that decision. I cannot unrequire rubygems, but you can not require it in the first place.

但是,当您创建代码库并与其他人共享代码库时,对于您“需要”的任何 Ruby 库,难道不能提出同样的论点吗?

最佳答案

如果你看评论,你会看到作者这样说

The point I was not trying to make is that rubygems is bad or that people shouldn’t use it. I use rubygems and think it’s a critical piece of Ruby’s success – I just don’t have the line “require 'rubygems'” anywhere in my library’s source code because it’s not necessary or convenient and makes it hard / impossible for other environments (like bundler, rip, GAE, debian, hand rolled, etc) to use the library without rubygems, which is often important.

其实我看之前不太同意他的观点,现在我同意了

关于ruby - 为什么是 "wrong to require rubygems"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1434259/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com