In swift value types can be done through structs. In structs the instance is storing the value only. the below code is going to explain the how it works
struct Student{
var name:String
}
var gulshan = Student(name:"Gulshan")
var mazeed = gulshan
mazeed.name = "Mazeed"
print(mazeed.name)
//prints the value as Mazeed
print(gulshan.name)
//prints the value as Gulshan
No comments:
Post a Comment