Hello guys and Welcome to Learn With Me: Apple's Swift.In previous tutorial you learned about Variables and Constants and today we are going to learn about Literals .So without wasting time let's start.
Literals are representations of fixed values in a program. They can be numbers, characters, or strings, etc. For example, "Hello, World!", 12, 23.0, "C", etc.
Swift supports 4 types of
•String and Character Literals.
So let's study about them in brief.
Integer literals are those that do not have a fractional or an exponential part.
There are four types of integer literals in Swift:
•A decimal number, with no prefix.
•A binary number, with a 0b prefix.
•An octal number, with a 0o prefix.
•A hexadecimal number, with a 0x prefix.
Floating-point literals are numeric literals that have floating decimal points or they are in fraction. For example,
Here,7.008 is a floating-point literal assigned to the radius constant.
There are only two Boolean Literals:true and false.
Character literals are Unicode characters enclosed in double quotes.For example,
String literals are sequences of characters enclosed in double quotes.For example,
Thanks for reading.I hope you will enjoy learning it.If you have any issues then let me know in the discussions.And in next part we are going to learn about Data Types in Swift.