Search
 
SCRIPT & CODE EXAMPLE
 

SWIFT

Swift Multiple Return Values

func returnMultipleValues() -> (String, Int, Double) {
    return ("Swift Tuple", 12, 3.14)
}

//Calling Function
let result = returnMultipleValues()

let nameString = result.0
let intValue = result.1
let doubleValue = result.2
Comment

Swift Function with Return Multiple Values

func checkMarks() -> (String, Int) {
  ...
  return (message, marks)
}
Comment

Swift Multiple Return Values

func compute(number: Int) -> (Int, Int, Int) {

  var square = number * number

  var cube = square * number
  
  return (number, square, cube)
}

var result = compute(number: 5)

print("Number:", result.0)
print("Square:", result.1)
print("Cube:", result.2)
Comment

PREVIOUS NEXT
Code Example
Swift :: swift 5 make a phone call 
Swift :: Fetch structure from userdefaults ios swift 
Swift :: swift constraint center vertically 
Swift :: button in swiftui 
Swift :: How to Programatically Exit Flutter App 
Swift :: swift test if simulator 
Swift :: for each swiftui 
Swift :: swiftui tabview 
Swift :: remove padding hstack swiftui 
Swift :: swift core data sort by date 
Swift :: swiftui scrollview 
Swift :: swift order dictionary by key 
Swift :: swift string to dictionary 
Swift :: swift convert base64 string to data 
Swift :: Swift Swift continue statement with nested loops 
Swift :: swift string time to epoch 
Swift :: swft image 
Swift :: defer swift 
Swift :: find range of string swift 
Swift :: swift fit label to text 
Swift :: and or in swift 
Swift :: Swift guard-let Statement 
Swift :: swift switch statement 
Swift :: tap to delete xcode 
Swift :: Working of Recursion in Swift 
Swift :: editbutton swiftui color text 
Swift :: Changing default url to static-media in Flask 
Swift :: fullscreencover swiftui 
Swift :: Swift Find Number of Dictionary Elements 
Swift :: Swift Modify Tuple Element 
ADD CONTENT
Topic
Content
Source link
Name
5+8 =