Author: Blogger
-
Numeric literals and formatting in Swift
Numeric literals can contain extra formatting to make them easier to read. Both integers and floating point numbers can eb padded with extra zero and underscores to help with readability. This won’t affect their value. Example: var integerFormatter = 5_000_000 var floatFormatter = 000_123.45
-
Decimal and Hexadecimal exponent in Swift
For decimal numbers with exponent value (e), the given number is multiplied by 10 to the power of exp. For hexadecimal numbers with exponent value (p), the given number is multiplied by 2 to the power of exp. Example: var decimalExponent = 25.5e3 var hexadecimalExponent = 0x345p-4
-
Floating Point Literals in Swift
Floating point literals can be of decimal or hexadecimal type. They must always have a number on both sides of decimal point. Example: var decimalFloat = 1.23 var hexadecimalFloat = 0xE.45
-
Integer literals in Swift
Integer literals in Swift are of the following types: Decimal literal Binary literal Octal literal Hexa decimal literal
-
Subscript Overloading in Swift
The concept of providing multiple subscripts for a class or structure is called as subscript overloading. The appropriate subscript which will be used during implementation depends upon the type of value contained within the subscript brackets when the subscript is used.
-
Subscript syntax in Swift
The subscript syntax is similar to instance method syntax and computed property syntax.
-
What are subscripts in Swift?
Classes, structures and enumeration can define subscripts which are shortcuts for accessing the members of collection, list or sequence. You can use subscripts to set and retrieve values by index without needing separate methods for setting and retrieval. You can define multiple subscripts for given type and appropriate subscript overload to be used is decided based […]