Swift diary of study#
Lately, I've been observing Swift, and I find myself quite intrigued by this programming language.
Through perusing various resources such as blogs and online articles, I stumbled upon an exceptional website for learning Swift: Hacking with Swift. The platform offers comprehensive tutorials, insightful explanations, and practical projects, making the learning process both engaging and effective. The clarity of instruction coupled with hands-on coding exercises has significantly enhanced my understanding of Swift's syntax and its underlying principles. I'm truly excited to delve deeper into Swift programming through the valuable resources provided by Hacking with Swift.
Day 1 and 2#
-
Swift lets us create constants using
let
, and variables usingvar
. -
If you don’t intend to change a value, make sure you use
let
so that Swift can help you avoid mistakes. -
Swift’s strings contain text, from short strings up to whole novels. They work great with emoji and any world language, and have helpful functionality such as
count
anduppercased()
. -
You create strings by using double quotes at the start and end, but if you want your string to go over several lines you need to use three double quotes at the start and end.
-
Swift calls its whole numbers integers, and they can be positive or negative. They also have helpful functionality, such as
isMultiple(of:)
. -
In Swift decimal numbers are called
Double
, short for double-length floating-point number. That means they can hold very large numbers if needed, but they also aren’t 100% accurate – you shouldn’t use them when 100% precision is required, such as when dealing with money. -
There are lots of built-in arithmetic operators, such as
+
,-
,*
, and/
, along with the special compound assignment operators such as+=
that modify variables directly. -
You can represent a simple true or false state using a Boolean, which can be flipped using the
!
operator or by callingtoggle()
. -
String interpolation lets us place constants and variables into our strings in a streamlined, efficient way.
此文由 Mix Space 同步更新至 xLog
原始链接为 https://www.ssstttar.com/posts/programming/Swift-diary-of-study(1)