Comparisment

   - compare programming languages by example

6

String literals

The syntax for literal strings.

Created by sam

Add a new answer

Either add an answer for a new language or add an alternative solution.
A description is only necessary when the code is not suitably 'obvious' or to justify an alternative approach.

Haskell

greeting :: String
greeting = "Hello World!"

A string is enclosed with double quote marks.

Created by: sam

Edit this answer

Edit the language, code and description simultaneously.

Haskell

greeting :: String
greeting = ['H','e','l','l','o',' ','W','o','r','l','d','!']

A string is a list of characters.

Created by: sam

Edit this answer

Edit the language, code and description simultaneously.

Python

greeting = "Hello World!"

A string is enclosed in double quotation marks.

Created by: sam

Edit this answer

Edit the language, code and description simultaneously.

Python

greeting = 'Hello World!'

A string may be enclosed in single quotation marks.

Created by: sam

Edit this answer

Edit the language, code and description simultaneously.