SLN SLN - 2 months ago 10
Swift Question

emoji cannot be a literal and what else?

A literal is the source code representation of a value of a type, such as a number or string

There are 3 kinds of literals in Swift: Integer Literals, Floating-Point Literals and String Literals (please correct me if I'm wrong), Is that means (My Guess) any elements which not belong to a type of Integer, Floating or String is not considered as a literal, and will trigger an error when used as literals

According to what I guess I've tried this
let aEmoji =

  1. Yes, anything that isn't an integer literal (1), floating-point literal (1.0) or String literal ("foo"), Array literal ([foo]), Dictionary literal ([foo : bar]), bool literal (true/false) isn't a literal and would cause an error.

  2. Anything that isn't one of the literals above isn't a literal, and could cause an error (if it's an invalid syntax).

You can make put an emoji in a string literal, however: let aEmoji = "