首页 > 学院 > 开发设计 > 正文

eval_api_类中类_map

2019-11-06 07:11:42
字体:
来源:转载
供稿:网友
(一)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
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表