返回顶部

收藏

extending Forwardable delegates to hash

更多
require 'forwardable'
class RandomAccessHash
  extend Forwardable
  def initialize
    @delegate_to = {}
  end

  def_delegators :@delegate_to, :[], '[]='
end

ra = RandomAccessHash.new

ra['A'] = 4.60
ra['B'] = 1.94
ra['C'] = 2.01
puts ra['D']                

标签:Ruby,集合

收藏

0人收藏

支持

0

反对

0

»更多 您可能感兴趣的代码
  1. 2016-08-28 12:09:13Inspect a set by 好好学习啊
  2. 2016-02-17 14:43:31Classify set elements as even or odd by Jamin
  3. 2016-08-28 12:16:49Compare two sets by LeoSun
  4. 2015-12-06 09:47:36to string by 好好学习啊
  5. 2015-12-30 10:38:27Set subtraction by 杨洋
  6. 2016-01-29 09:46:42Easing the Delegation Blues by 胡晋
  7. 2016-08-27 21:28:07include Comparable by 好好学习啊
  8. 2016-08-28 12:27:21Divide with block by jeffsui
  9. 2016-02-22 20:29:27Create set with constant values by Loli控
  10. 2016-03-09 13:03:04Create Your tree by JustForFly
  11. 2016-08-27 21:39:08get Enumerable involved by LeoSun

发表评论