Last active
October 27, 2021 05:56
-
-
Save JarvisTheAvenger/2af8684ec453c7c276dc81f7c1236f75 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
// Subscript are used to access the information from collection, sequence and a list in classes, structures and enumerations | |
class DaysOfWeek { | |
var days = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"] | |
subscript(index: Int) -> String { | |
get { | |
return days[index] | |
} | |
set { | |
days[index] = newValue | |
} | |
} | |
} | |
let object = DaysOfWeek() | |
print(object[0]) // Monday |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment