ruby 1.8.6中的ruby 1.9方法 [英] ruby 1.9 methods in ruby 1.8.6

查看:113
本文介绍了ruby 1.8.6中的ruby 1.9方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有宝石或图书馆来获取ruby 1.9方法,如

Is there a gem or a library to get ruby 1.9 methods like

[1, 2, 3].combination(2)
[1, 2, 3].permutation(2)
[1, 2, 3].product([1, 2, 3])
[1, 2, 3, 4, 5].cycle

推荐答案

这正是我的瑰宝的目标 backports .

This is exactly the goal of my gem backports.

它在纯Ruby中实现Ruby 1.8.7以及Ruby 1.9.x和2.0的许多新功能.当然,这包括#combination#permutation#product#cycle.

It implements in pure Ruby all the new features of Ruby 1.8.7 and many of Ruby 1.9.x and 2.0. This of course includes #combination, #permutation, #product and #cycle.

您可以,例如:

require 'backports/1.8.7/array/combination'
[1, 2, 3].combination(2) # => works, even in Ruby 1.8.6

backports中的实现会通过大多数 RubySpecs (对于facets而言并非如此)来保证没有兼容性问题.

The implementation in backports pass most RubySpecs (which is not the case for facets) to guarantee not having compatibility problems.

这篇关于ruby 1.8.6中的ruby 1.9方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆