返回顶部

收藏

ruby访问内置类

更多
class Drawing
  def Drawing.give_me_a_circle
    Circle.new
  end

  class Line
  end

  class Circle
    def what_am_i
      'This is a circle'
    end
  end
end

a = Drawing.give_me_a_circle
puts a.what_am_i
a = Drawing::Circle.new
puts a.what_am_i
a = Circle.new
puts a.what_am_i

标签:Ruby,OOD

收藏

0人收藏

支持

0

反对

0

»更多 您可能感兴趣的代码
  1. 2016-01-12 21:33:50print Statement by 好好学习啊
  2. 2016-01-15 10:56:03YAML for Marshaling by Loli控
  3. 2016-01-18 13:26:44Extracting All the URLs from an HTML Document by LeoSun
  4. 2016-01-20 11:58:39Array with Array.new by Ω油菜
  5. 2016-01-22 20:52:08Euler and PI by 胡晋
  6. 2016-01-24 20:43:12Escape sequence and hex number by Loli控
  7. 2016-01-26 20:21:24Wakeup main thread by JustForFly
  8. 2016-01-29 17:16:54For each element in a range by Jamin
  9. 2016-02-01 09:40:32max_by with block by 杨洋
  10. 2016-02-04 09:31:36Add method implementation for object instance by zetaliang
  11. 2018-03-30 21:56:50java自动识别用户上传的文本文件编码 by Hugh

发表评论