0

In several languages, one can forgo single quotation marks ' completely. For example in Python, single quotation marks can always be replaced with double quotation marks

'string' == "string"

In Ruby, single quotation marks can be used to encode raw strings; but one can alternatively use another syntax:

'string' == %q(string)

Question: in which programming languages do single quotation marks ' play a unique role that cannot be replaced?

The same question put differently: in which programming languages does one get handicapped if their single quotation mark ' key is broken?

Damien L
  • 161
  • 6

3 Answers3

1

No difference between ' and ": python, node.js

Difference between ' and ": c, c++, c#, go, prolog, ruby, bash, SQL, java

In C, C++, C#, Go you can replace 'a' with "a"[0]

In java you can do "a".charAt(0)

In ruby and bash the difference is interpolation, so you need to use " instead of ', but you need to escape special signs.

The difference in Prolog is depicted here

Vulwsztyn
  • 2,140
  • 1
  • 12
  • 20
1

Pascal and derivatives use single quotes to denote strings, while double quotes have no special meaning.

0

Java can be written entirely in UTF-16 escape sequences which are interpreted before compilation, so you could replace any ' with \u0027.

Tech Inquisitor
  • 343
  • 1
  • 7