Ruby中的三重单引号与三重双引号 [英] Triple single quote vs triple double quote in Ruby

查看:186
本文介绍了Ruby中的三重单引号与三重双引号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么要使用'''而不是,如学习Ruby的难点,第10章学习练习

Why might you use ''' instead of """, as in Learn Ruby the Hard Way, Chapter 10 Study Drills?

推荐答案

Ruby中没有三重引号。

There are no triple quotes in Ruby.

两个 String String literal。所以,

Two String literals which are juxtaposed are parsed as a single String literal. So,

'Hello' 'World'

'HelloWorld'

p>

And

'' 'Hello' ''

'''Hello'''

'Hello'

三重单引号与三重双引号没有特殊规则,因为不是三重引号。这些规则与引号一样。

There are no special rules for triple single quotes vs. triple double quotes, because there are no triple quotes. The rules are simply the same as for quotes.

这篇关于Ruby中的三重单引号与三重双引号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆