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 :: swiftui show custom loading spinner 
Swift :: Swift continue Statement With for Loop 
Swift :: Swift s for complex types 
Swift :: uitableview disable sticky header 
Swift :: swift array to data 
Swift :: how to know when text changed textfield swiftui 
Swift :: cifilter image preserve orientation 
Ruby :: see all rails routes in browser 
Ruby :: devise generate controller 
Ruby :: rails resources except 
Ruby :: check current route rails 
Ruby :: rails get current database name 
Ruby :: reverse range ruby using steps 
Ruby :: ruby get file name 
Ruby :: rails form select 
Ruby :: rails update without callback 
Ruby :: rails find_by order 
Ruby :: ruby run bash command 
Ruby :: rails redirect_to with params 
Ruby :: ruby not include 
Ruby :: creating model in ruby on rails 
Ruby :: Rails validations: unique scope 
Ruby :: ruby list of files in directory include subfolders 
Ruby :: What does inject in ruby do 
Ruby :: ruby array split into groups 
Ruby :: ruby shorthand if 
Ruby :: ruby assign value to hash 
Ruby :: map each with index 
Ruby :: Error occurred while parsing request parameters. 
Ruby :: devise valid password 
ADD CONTENT
Topic
Content
Source link
Name
5+2 =