VNUHCM
Bài trước Bài kế tiếp
  • Nội dung học
  • Trợ giúp
    Bạn có thắc mắc khi đang học?
    Hướng dẫn cách học Những câu hỏi thường gặp Email cho giáo vụ
    • Tiếng Việt
    • English
    • Thông tin Thành viên
    • Khoá học đăng ký
    • Đăng xuất
  • Cohota
  • HƯỚNG DẪN HỌC TẬP

  • Xem chi tiết >>
    Bạn đã hoàn thành 0% khoá học
  • HƯỚNG DẪN SINH VIÊN ĐĂNG NHẬP HỆ THỐNG
    • Hướng dẫn đăng nhập
    • Hướng dẫn vào khóa học
  • Introduction
    • Welcome
  • Unit 1: Values
    • Introduction - Unit 1: Values
    • Get Started With Values
    • Play with Values
    • Playground Basics
    • Naming and Identifiers
    • Simulation
    • Strings
    • Constants and Variables
    • Word Games
    • Build a PhotoFrame App
    • Design for People
  • Episode 1: The TV Club
    • Introduction - Episode 1: The TV Club
    • Searching for Content
    • Sharing Personal Information
    • Ordering Online
    • Reflection: Episode 1
  • Unit 2: Algorithms
    • Introduction - Unit 2: Algorithms
    • Get Started with Algorithms
    • Play with Programs
    • Functions
    • Types
    • Parameters and Results
    • Making Decisions
    • BoogieBot
    • Data Visualization
    • Build a QuestionBot App
    • Design an Experience
  • Episode 2: The Viewing Party
    • Introduction - Episode 2: The Viewing Party
    • Accessing the Show
    • Streaming on the Network
    • Reflection: Episode 2
  • Unit 3: Organizing Data
    • Introduction - Unit 3: Organizing Data
    • Get Started with Organizing Data
    • Play with Complex Data
    • Instances, Methods, and Properties
    • Arrays and Loops
    • Structures
    • Enums and Switch
    • Testing Code
    • Processing Data
    • Pixel Art
    • Password Security
    • Visualization Revisited
    • Build a BouncyBall App
    • Design a Prototype
  • Episode 3: Sharing Photos
    • Introduction - Episode 3: Sharing Photos
    • Capturing Images
    • Posting on Social Media
    • Reflection: Episode 3
  • Unit 4: Building Apps
    • Introduction - Unit 4: Building Apps
    • Get Started with App Development
    • Play with App Components
    • Color Picker
    • ChatBot
    • Rock, Paper, Scissors
    • MemeMaker
    • Build an ElementQuiz App
    • Design for Impact
  • Appendix
    • Episode Technical Concepts
    • Glossary
Tổng quan điểm khóa học
Đánh giá

Tiến độ
Tên tiêu chí Trọng số (%) Điểm Tiến độ (%)
Unit 2: Algorithms

Types

Unit 2: Algorithms|Play

What you'll build

  • A program to calculate the circumference of a circle.

What you'll learn

  • How types are used to distinguish different kinds of values, and that every value used in a program has a type.
  • How Swift makes sure types are used correctly.
  • How Swift will try to infer the type of values.

Key vocabulary

  • Framework
  • Integer
  • Type
  • Type annotation
  • Type inference

Introduction

Everything around you is a type of something. People divide things into types, or classifications, based on commonly understood features and capabilities. You know what a pencil is, what you can do with it, and when you might want to use a pencil rather than a pen. In this lesson, you’ll learn that the values in your programs also fall into classifications that affect what they can do and what you might want to use them for.

Go Build

Open the Types.playground file in your course resources and follow the instructions.

Screenshot of the Types playground

Reflection Questions

Think of a single screen of an app you use. How many different types of information do you think are involved?

Can you think of other types beyond strings and numbers?

How would you write a program that deals with a music collection?

What types might you need?

Summary

Careful use of types will make your programs easier to understand and easier to write. Swift contains protections to notify you if you’re using types incorrectly.

You also added to your list of kinds of expressions. Now you know that expressions either can be literal values or can use a combination of mathematical operators.

You’ve now scratched the surface of the vast range of types available to you in the Swift standard library and the Foundation framework. As you progress through more lessons, you’ll get to know more types and you’ll also create your own.

Báo lỗi