【问题标题】:Ruby << for String [duplicate]Ruby << for String [重复]
【发布时间】:2013-12-06 08:16:47
【问题描述】:

谁能告诉我名字

<<-MAP 
STRING HERE
MAP

红宝石中的运算符(&lt;&lt;-)?我尝试搜索“双倍以下”,但没有出现任何结果。我想进一步了解它,但我什至不知道它叫什么!

谢谢

【问题讨论】:

    标签: ruby


    【解决方案1】:

    这就是所谓的here doc语法。一般用于输入多行字符串。你可以在这里阅读它http://blog.jayfields.com/2006/12/ruby-multiline-strings-here-doc-or.html

    还有这里The <<- operator on Ruby, where is it documented?

    【讨论】:

      【解决方案2】:

      这不是一个运算符,它是一个 here 文档(又名 heredocString 文字。它的工作方式或多或少类似于其他语言的 heredocs。

      它在 ISO Ruby 语言规范的第 8.7.6.3.6 节中指定。

      【讨论】:

        猜你喜欢
        • 2014-10-29
        • 1970-01-01
        • 1970-01-01
        • 2011-03-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-03-19
        • 2017-06-07
        相关资源
        最近更新 更多