Run Swift

let iterations = 1000000 // simple struct SimpleStruct { let value: UInt8 let anotherValue: UInt16 func setValue(value: UInt8) -> SimpleStruct { return SimpleStruct(value: value, anotherValue: anotherValue) } } class SimpleClass { let value: UInt8 let anotherValue: UInt16 init(value: UInt8, anotherValue: UInt16) { self.value = value self.anotherValue = anotherValue } func setValue(value: UInt8) -> SimpleClass { return SimpleClass(value: value, anotherValue: anotherValue) } } let structStartDate = NSDate() var aStruct = SimpleStruct(value: 1, anotherValue: 2) for v in 0.. ComplexStruct { var newValues = values newValues[0] = value return ComplexStruct(values: newValues) } } class ComplexClass { let values: [UInt8] init(values: [UInt8]) { self.values = values } func setFirstValue(value: UInt8) -> ComplexClass { var newValues = values newValues[0] = value return ComplexClass(values: newValues) } } let complexStructStartDate = NSDate() var complexStruct = ComplexStruct(values: [1]) for v in 0..
  

* Foundation framework not available
 

Run Swift is a web tool where you can easily try Apple's Swift language online. Just paste any snippet, switch to the Swift version you prefer (either 2.2 - without Foundation support - or 3.0) and click    Run . You may also    Save  your scripts and/or share with the world. If what you're looking for is an easy-to-use tool for your Mac, to quickly test and run Swift code, then you may want to have a look at our Run Swift app for MacOS.