What character do we use in Swift if we don't want the values of indices in a for-in loop?
What will be the output of the following lines of code?
var someType = ["1":1,"2":2,"3":3]
print(type(of: someType["1"]))
If we provide a custom property setter to an inherited property, which of the following cannot be added to that inherited property?
What will be the output of the following code?
func greet(person: String) -> String {
let greeting = "Hello, " + person + "!"
return greeting
}
If you want to declare a property in Swift where the value of the variable is dependent on some external factors, what kind of property would be the best to use?
What are value types in Swift?
Complete the sentence/ Fill in the blank:
A value type is a type whose value is copied when it's assigned to a variable or constant, or when it's passed to a function.
Why are substrings used in Swift?
What will be the output of the following code?
enum Cardinal {
case north, south, east, west
}
var directionToHead = Cardinal.north
directionToHead = .south
switch directionToHead {
case .north:
print("N")
case .south:
print("S")
case .east:
print("E")
case .west:
print("W")
}
What will be the output of the following code?
let string = "String"
var str = String()
for char in string {
switch char {
case "s": str.append("1")
case "i": str.append("2")
case "g": str.append("3")
default: str.append(String(char))
}
}
print(str)
What will be the output of the following lines of code?
var cInLine = ["Rajiv", "Rahul", "Maitreye"]
func serve(customer customerProvider: @autoclosure () -> String) {
print("Now serving \(customerProvider())")
}
serve(customer: cInLine.remove(at: 0))
OnSite
1 Openings
FullTime
Posted 17 days ago