mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
The old ones were: - print/println - printAny - printf - Console The new printing story is just print/println. Every object can be printed. You can customize the way it is printed by adopting Printable protocol. Full details in comments inside stdlib/core/OutputStream.swift. Printing is not completely finished yet. We still have ReplPrintable, which should be removed, string interpolation still uses String constructors, and printing objects that don't conform to Printable will result in printing mangled names. Swift SVN r18001
32 lines
703 B
Swift
32 lines
703 B
Swift
// RUN: %target-run-simple-swift | FileCheck %s
|
|
|
|
// iOS doesn't have NSRect. iOS and OS X CGRect is tested elsewhere.
|
|
// REQUIRES: OS=macosx
|
|
|
|
import Foundation
|
|
|
|
func printRect(r: NSRect) {
|
|
// FIXME: Constraint checker takes too long to typecheck this as an
|
|
// interpolation expression
|
|
print("NSRect(")
|
|
print(r.origin.x)
|
|
print(", ")
|
|
print(r.origin.y)
|
|
print(", ")
|
|
print(r.size.width)
|
|
print(", ")
|
|
print(r.size.height)
|
|
println(")")
|
|
}
|
|
|
|
var r = NSRect(x: 0, y: 0, width: 100, height: 50)
|
|
|
|
// CHECK: NSRect(20, 10, 60, 30)
|
|
printRect(NSInsetRect(r, 20, 10))
|
|
|
|
// CHECK: NSRect(100, 100, 50, 50)
|
|
printRect(NSMakeRect(100,100,50,50))
|
|
|
|
// CHECK: {0, 0}, {100, 50}
|
|
println(NSStringFromRect(r))
|