eval_api_类中类_map

来源:互联网 发布:淘宝宝贝标题敏感 编辑:程序博客网 时间:2024/05/16 08:12
(一)eval("a=1;b=2;puts a+b")
运行结果vagrant@vagrant-ubuntu-trusty-64:/vagrant/test_project$ ruby Apple4.rb3
(二)查看apiReference Documentation就是API
(三)类中类及类中类之方法
class Fruit  COLOR='red'  class Apple    COLOR='red'    def size      puts 'big'    end  endendputs Fruit::Apple::COLORputs Fruit::Apple.new.size
运行结果
vagrant@vagrant-ubuntu-trusty-64:/vagrant/test_project$ ruby Apple4.rbredbig
(四)map用法
result=[1,2,3].map do |e|  e*eendputs result.inspect


0 0