What is the keyword used to define subscripts in Swift?
A protocol in Swift can extend itself.
What is the name of the argument Swift uses in computed properties by default for a setter?
What is the correct way to declare and define required initializers in Swift?
What is the mechanism that handles instance memory management in Swift?
Which of the following is a valid rule for initializers in Swift?
What will be the output of the following lines of code?
class Test {
var x: Int = 0
func printSomething() {
x += 1
}
}
var test = Test()
test.printSomething()
print(test.x)
What will be the output of the following code?
let hours = 12
let hourInterval = 3
var ticks = [Int]()
for tickMark in stride(from: 3, through: hours, by: hourInterval) {
ticks.append(tickMark)
}
print(ticks)
To declare property wrappers in Swift, we need to use a certain keyword. Where do we place this keyword in the statement to successfully declare a property wrapper?
What will be the output of the following code?
struct SomeStruct {
var someArr = [1, 2, 3, 4]
subscript(i: Int) -> Int {
get {
return someArr[i]
}
set {
someArr[i] = newValue
}
}
}
var someIns = SomeStruct()
someIns[3] = 5
print(someIns.someArr)
OnSite
1 Openings
FullTime
Posted 17 days ago