Tuples

This page is under construction. Please come back later.
#!/usr/bin/env swift;
import Foundation
import Utils
func main() -> Void {
var pair1 = ("Hello", 5)
var pair2:(Int, Double)
var pair3:(String, Double)
pair2 = (3, 3.1415926)
pair3 = ("Goodbye", 1.5)
print(pair1.0 + "," + String(pair1.1))
print(String(pair2.0) + "," + String(pair2.1))
print(Utils.tupleToString(pair3))
exit(EXIT_SUCCESS)
}
main()
Output
$ swiftc Tuples1.swift -I . -L . -lUtils
error: link command failed with exit code 1 (use -v to see invocation)
ld: library not found for -lUtils
clang: error: linker command failed with exit code 1 (use -v to see invocation)
#!/usr/bin/env swift;
import Foundation
func main() -> Void {
var pair1 = ("Hello", 5)
var tuple1 = ("Goodbye", 3, 3.1415926)
var tuple2 = (1.6, 2.5, 5, "C")
print(pair1.0 + "," + String(pair1.1))
print(tuple1.0 + "," + String(tuple1.1) + "," + String(tuple1.2))
print(String(tuple2.0) + "," + String(tuple2.1) + "," + String(tuple2.2) + "," + tuple2.3)
exit(EXIT_SUCCESS)
}
main()
Output
$ swiftc Tuples2.swift -I . -L . -lUtils
error: link command failed with exit code 1 (use -v to see invocation)
ld: library not found for -lUtils
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Questions
- {{Who's on first?}}
- {{Who's on second?}}
- {{Who's on third?}}
Projects
More ★'s indicate higher difficulty level.
References
- [[Swift Community]]
- [[Swift Language Guide]]
- [[Swift Language Reference]]
- [[Swift Programming Language]], Apple Inc.
- [[Swift Doc]]
- [[We Heart Swift]]
- [[Swift Cookbook]]
- [[Swift Playground]]
- [[Swift at TutorialsPoint]]
- [[Hacking with Swift]]
Pure Programmer


