Swift--Swift code

Source: Internet
Author: User
Tags mul

Property Monitor

Class square{

var width:double = 0 {

willset{

println ("willset--newvalue = \ (newvalue), CurrentValue = \ (width)")

}

didset{

println ("didset--oldValue = \ (oldValue), CurrentValue = \ (width)")

}

}

var girth:double {

get{

Return width * 4

}

set{

println ("Call the Set method of girth")

width = NEWVALUE/4

}

}

}

var s = Square ()

S.width = 5

S.girth

S.girth = 200

******************************************

The first parameter name of a method is only a local parameter name, and the other parameter name is both a local parameter name and an external parameter name

Class calculate{

Func sum (num1:int, num2:int), int{

return NUM1 + num2

}

Func Mul (Num1:int, Number2 num2:int, _ Num3:int), int{

return NUM1 * num2 * num3

}

}

var c = Calculate ()

C.sum (9, Num2:10)

C.mul (3, Number2:9, 10)

Swift--Swift code

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.