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 :: set time programmatically swift 
Swift :: Swift enum With Associated Values 
Swift :: Logical Operators Swift 
Swift :: table flutter stackoverflow 
Swift :: how to scroll to section in tableview swift 
Swift :: multiline comment in swift 
Swift :: swift variables 
Swift :: spacing in uitextfield 
Swift :: Button on right side/view of UITextField 
Swift :: rust How to pass out parameter to function from Swift FFI 
Swift :: Example: Multiple Return Values 
Swift :: swift integer 
Swift :: change button image tint color swift 
Swift :: swift print statement 
Swift :: swift uibutton text resets to default 
Swift :: swift 5 for loop with index <= 
Swift :: swift function return type 
Swift :: Swift Deinitialization 
Swift :: ios network request 
Swift :: UITableViewRowAction access button 
Ruby :: ruby json parse symbolize_keys 
Ruby :: create table if not exist rails 
Ruby :: simple form for rails dates 
Ruby :: rails form select 
Ruby :: ruby deep merge 
Ruby :: rails crud 
Ruby :: date time string to time in rails 
Ruby :: array to hash ruby 
Ruby :: rails convert unix timestamp to datetime 
Ruby :: what is ruby language used for 
ADD CONTENT
Topic
Content
Source link
Name
3+7 =