(Swift for Beginners) Swift Ternary Conditional Operator In this article, you will learn to use conditional or ternary operator to alter control flow of the program. The ternary conditional operator “? :” is a shorthand for if-else statement. The syntax for ternary conditional operator is: condition ? value1 : value2 How ternary conditional operator works? Here’s how …
(Swift for Beginners) Swift Operator precedence and associativity In this article you will learn about the rules used to evaluate a expression with operators and operands. Swift Operator precedence Operator precedence is a collection of rules used in order to evaluate a given mathematical expression. When there are several operators used in a single expression, …
(Swift for Beginners) Swift Operators In this article, you’ll learn everything about different types of operators in Swift programming language, their syntax and how to use them with examples. Operators are special symbols (characters) that carry out operations on operands (variables and values). Some basic operations includes assigning, changing, combining and checking values. For example, + is …
(Swift for Beginners) Swift Comments In this article, you will learn about Swift comments, why and how to use them. A comment is a programmer-readable explanation or annotation in the source code of a program. It is ignored by the compiler when the code is compiled. Comments are intended for person reading the code to better understand …
(Swift for Beginners) Swift Expressions, Statements and Code blocks In this article, you will learn about Swift expressions, statements and blocks. In the previous chapter, we used expressions, statements and blocks without explaining what it is although it’s used in every Swift program. After you know what variables, operators are it will be easier to …
(Swift for Beginners) Swift Basic Input and Output In this article, you will learn different ways to display output and get input in Swift. Swift Basic Output You can simply use print(_:separator:terminator:) function to send output to standard output (screen). See Swift function article to learn about functions in Swift. The function print(_:separator:terminator:) accepts three parameters. items: Items to print in the …
(Swift for Beginners) Swift Characters and Strings In this tutorial, you will learn about characters and strings usage in Swift. You’ll also learn different operations that can be performed on strings and characters. What is a character? A character is a single symbol (letter, number, etc.). Character in swift are of Character type and is declared as: …
(Swift for Beginners) Swift Optionals In this article, you will learn about optional, its use cases and optional handling in Swift. In the previous article, we learned about different data types available in Swift and also noticed variable or constant declared of those types contains a default value. Example: let someValue = Int() print(someValue) When …
(Swift for Beginners) Swift Data Types In this tutorial, you will learn about different data types that Swift programming language supports and use it while creating a variable or a constant. A data type is the type of data (value) a variable or constant can store in it. For example, in the article Swift Variables …
(Swift for Beginners) Swift Variables, Constants and Literals In this article, you will learn about variables, constants, literals and their use cases in Swift programming. What is a Variable? In programming, variables are used to store data in memory which can be used throughout the program. Each variable must be given a unique name …