如何在宏中执行正则表达式?
How-to do regex in macros?
{% nilable = /\:\:Nil|\?$/.match(type) %}
它似乎不起作用:undefined macro method 'RegexLiteral#match'
。
Macros::StringLiteral
有 =~
个实例:
{% type = "Module::Nil" %}
{% p type =~ /\:\:Nil|\?$/ %} #=> true
{% type = "Module::Null" %}
{% p type =~ /\:\:Nil|\?$/ %} #=> false
{% nilable = /\:\:Nil|\?$/.match(type) %}
它似乎不起作用:undefined macro method 'RegexLiteral#match'
。
Macros::StringLiteral
有 =~
个实例:
{% type = "Module::Nil" %}
{% p type =~ /\:\:Nil|\?$/ %} #=> true
{% type = "Module::Null" %}
{% p type =~ /\:\:Nil|\?$/ %} #=> false