Thursday, June 04, 2015

[swift] Hello Swift [part 2]

[swift] Hello Swift [part 2]
The conclusion before writing Swift language

7.  Passing parameter with inout keyword
Assigning reference value of Swift language can use inout keyword and when you pass object by argument you will use & in front of object name
Be careful, inout keyword cannot set object when you declare object with let,var keyword

8.  Returning data type from function or method
Some function, when you declare function or method, you want to return something from the function you may use -> to declare it
For example:  
func plus(x:Int,y:Int)->Int{
return x+y
}

9. Data Type in swift
Currently, data type on Swift are contained in struct no matter primitive or classes
Int , String are Value Type
class is Reference Type

10.  Declaring constructor in Swift
You may create constructor of class in Swift by init keyword as follow:
init(){
}
It’s pattern similar to method, but it’s constructor that is called automatically when you create new instance of object

11. Using for Loop
Using for lop as if you create one or many statement you must need { } sign
12.  Assigning value have to be space
Assigning variables, Space is always required such as var temp = “temp value”


Hopefully, it will be prepared to use Swift language perfectly, good luck all.
Bottom of Form

No comments: