基础篇
本篇中的7个章节,主要讲解从计算机工作底层机制到数据结构这些Swift编程的基础,通过这些基础知识的学习,你可以从容的编写和组织自己的代码。这些基础知识包括以下内容:
第一章,必备编程基础和背景知识: 本章将简单介绍编程和计算机,然后使用swift编写第一个hello程序。
第二章,变量 常量和表达式:本章讲解变量,常量,表达式以及注释。swift在很多基础的代码片段,使用方式和展示方式上, 与其他语言并没有非常大的区别。
第三章,类型及操作:本章讲解不同的数据类型,比如使用Strings类型来表示文本内容。同时会讲解类型转换和类型推断,类型推断应该是其他几种语言不常用的。然后你将学习如何将不同类型的数据封装成一个多元组对象,在掌握了这些数据类型之后,你就可以使用他们实现一些基本功能了。
第四章,基础控制:本章将讲解各种分支判断,循环逻辑和Boolean的使用,以及使用Boolean来表示数据对比的结果。
第五章,循环执行:本章将讲解除了for循环之外一种循环语法,同时介绍switch语句,这个语句再swift语言里面尤其强大。
第六章,函数:函数是代码块,将代码分块是为了提高代码的复用性。将重复被使用和执行的代码单独组合成函数,有利于提高代码的内聚,降低耦合度。
第七章,Optionals:(我还没想好怎么翻译这个数据类型): optionals是swift语言特有的数据类型,他要么代表一种真实的值,要么就是表示一个并不存在的值,本章的结尾,你会意识到这个类型多么的有用,以及如何安全的使用这种数据。------这个变量的具体意义我还需要学习之后再回来修改一下,暂时的字面的意思,应该是表示一个值的引用变量或者一个没有初始化的变量。 我学习完这一章之后会重新修改这段翻译。
Section I: Swift Basics
The chapters in this section will introduce you to the very basics of programming in
Swift. From the fundamentals of how computers work all the way up to language
structures, you’ll cover enough of the language to be able to work with data and
organize your code’s behavior.
The section begins with some groundwork to get you started:
•Chapter 1, Coding Essentials & Playground Basics: This is it, your whirlwind introduction to the world of programming! You’ll begin with an overview of
computers and programming and then say hello to Swift playgrounds, which are
where you’ll spend your coding time for the rest of this book.
Next, you’ll learn the basics of data in Swift:
Chapter 2, Expressions, Variables & Constants: You’ll start by learning some
basics such as code comments, arithmetic operations, constants, and variables.
These are some of the fundamental building blocks of any language, and Swift is
no different.
Chapter 3, Types & Operations: You’ll learn about handling different types,
including strings which allow you to represent text. You’ll learn about converting
between types and you’ll also be introduced to type inference which makes your
life as a programmer a lot simpler. You’ll learn about tuples which allow you to
make your own types made up of multiple values of any type.
Once you have the basic data types in your head, it’ll be time to do things with that
data:
Chapter 4, Basic Control Flow: You’ll learn how to make decisions and repeat
tasks in your programs by using syntax to control the flow. You’ll also learn about Booleans, which represent true and false values, and how you can use these to
compare data.
Chapter 5, Repeating Steps: Continuing the theme of code not running in a
straight line, you’ll learn about another loop known as the for loop. You’ll also
learn about switch statements which are particularly powerful in Swift.
Chapter 6, Functions: Functions are the basic building blocks you use to
structure your code in Swift. You’ll learn how to define functions to group your
code into reusable units.
The final chapter of the section loops a very important data type:
•Chapter 7, Optionals: This chapter covers optionals, a special type in Swift that
represents either a real value or the absence of a value. By the end of this
chapter, you’ll know why you need optionals and how to use them safely.
These fundamentals will get you Swiftly on your way, and before you know it, you’ll
be ready for the more advanced topics that follow. Let’s get started!
网友评论