Swift first glance ---- syntax, swift first glance ----

Source: Internet
Author: User

Swift first glance ---- syntax, swift first glance ----

Swift knowledge point

The following describes what to use to write Swift code. First, Swift does not have a header file and A. H file.

Variable Declaration

Swift variable Declaration has two keywords: var AND let. var is similar to javascript. You can declare any type of object and specify the type through var mystring: String.

var myVariable = 42myVariable = 50let myConstant = 42

Function

Swift function expression, which is the same as the javascript keyword, is func, followed by the function name. Note that the parameters in brackets are respectively the name, type String, and name day, type String, where-> String is the type of the function return parameter.

func greet(name: String, day: String) -> String {    return "Hello \(name), today is \(day)."}greet("Bob", "Tuesday")


Class and Object

Class Declaration, in which the class method is defined in the braces of the class.

class Shape {    var numberOfSides: Int = 0    func description() -> String {        return "A shape with \(numberOfSides) sides."    }}


Protocol

protocol ExampleProtocol {    var simpleDescription: String { get }    mutating func adjust()}

Syntax problems in taylor swift lyrics

There is a commonly used method for omitting the title of a newspaper. The active method uses ing and the passive method uses the past word segmentation.
For example, stuck in traffic is a traffic jam.
This is similar, but it is more about rhyming. It is very common to omit the lyrics. Chinese lyrics are not very syntactic.
Complete should be I have been ....
Or the Passive Meaning of "I am stuck here but you cannot see it"
However, regular articles cannot be used.
This is my idea for reference.
Haha ..........

Syntax in the lyrics of taylor swift's red album

Generally, the lyrics do not focus on syntaxes, or even some syntaxes are incorrect. Therefore, it is not good to listen to English songs and learn grammar.
 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.