a literal source code representation of value of type, such number or string
there 3 kinds of literals in swift: integer literals, floating-point literals , string literals (please correct me if i'm wrong), means (my guess) elements not belong type of integer, floating or string not considered literal, , trigger error when used literals
according guess i've tried let aemoji = 😀
question1: guess accurate? if not, appreciate correct me.
question2: there else shouldn't use literal? (would nice give me example)
thanks
yes, isn't 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 literal , cause error.anything isn't 1 of literals above isn't literal, , cause error (if it's invalid syntax).
you can make put emoji in string literal, however: let aemoji = "😀"
Comments
Post a Comment