这个功能要模拟Groovy中Expando和Javascript中的{},这里要用到ruby自带的osstruct库

 

#!C:/Ruby192/bin/ruby.exe

require 'ostruct'

def mytest 
puts "a method"
end 
o = OpenStruct.new
o.method1 = mytest
o.prop1 = "a property"
puts o.method1
puts o.prop1
 

  

相关文章:

  • 2021-10-11
  • 2021-06-03
  • 2022-12-23
  • 2021-07-03
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-12-21
  • 2021-06-22
  • 2021-12-19
  • 2022-12-23
  • 2022-12-23
  • 2021-08-17
相关资源
相似解决方案