Update to Swift 1.2

- countElements() renamed to count()

Via release notes
- "The notions of guaranteed conversion and “forced failable” conversion are now
   separated into two operators. Forced failable conversion now uses the as!
   operator. The ! makes it clear to readers of code that the cast may fail and
   produce a runtime error. The “as” operator remains for upcasts
   (e.g. “someDerivedValue as Base”) and type annotations (“0 as Int8”) which
   are guaranteed to never fail."
- "The implicit conversions from bridged Objective-C classes
   (NSString/NSArray/NSDictionary) to their corresponding Swift value types
   (String/Array/Dictionary) have been removed, making the Swift type system
   simpler and more predictable."
- "The @autoclosure attribute is now an attribute on a parameter, not an
   attribute on the parameter’s type."
This commit is contained in:
beltex
2015-02-13 12:28:36 -05:00
parent 9555306183
commit 9c69f0b1bc
3 changed files with 6 additions and 6 deletions
+2 -2
View File
@@ -29,7 +29,7 @@ left side as standard input.
Warning: is only meant to be used with the "run" command, but could also unintentionally catch other uses of
"ReadableStreamType |> ReadableStreamType", though that statement doesn't make any sense.
*/
public func |> (lhs: ReadableStreamType, rhs: @autoclosure () -> ReadableStreamType) -> ReadableStreamType {
public func |> (lhs: ReadableStreamType, @autoclosure rhs: () -> ReadableStreamType) -> ReadableStreamType {
assert(_nextinput_ == nil)
_nextinput_ = lhs
let result = rhs()
@@ -49,7 +49,7 @@ public func run (shellcommand: String) -> ReadableStreamType {
let task = newtask(shellcommand)
if let input = _nextinput_ {
task.standardInput = input as FileHandle
task.standardInput = input as! FileHandle
_nextinput_ = nil
} else {
// avoids implicit reading of the main script's standardInput
+3 -3
View File
@@ -19,7 +19,7 @@ extension FileHandle: ReadableStreamType {
return nil
} else {
if let result = NSString(data: data, encoding: streamencoding) {
return result
return result as String
} else {
printErrorAndExit("Fatal error - could not read stream.")
}
@@ -29,7 +29,7 @@ extension FileHandle: ReadableStreamType {
public func read () -> String {
let data: NSData = self.readDataToEndOfFile()
if let result = NSString(data: data, encoding: streamencoding) {
return result
return result as String
} else {
printErrorAndExit("Fatal error - could not read stream.")
}
@@ -114,7 +114,7 @@ public func open (forWriting path: String, overwrite: Bool = false) -> Writeable
}
public let environment = NSProcessInfo.processInfo().environment as [String: String]
public let environment = NSProcessInfo.processInfo().environment as! [String: String]
public let standardinput = FileHandle.fileHandleWithStandardInput() as ReadableStreamType
public let standardoutput = FileHandle.fileHandleWithStandardOutput() as WriteableStreamType
public let standarderror = FileHandle.fileHandleWithStandardError() as WriteableStreamType
+1 -1
View File
@@ -33,7 +33,7 @@ extension String {
}
public func countOccurrencesOf (substring: String) -> Int {
return self.findAll(substring) |> toArray |> countElements
return self.findAll(substring) |> toArray |> count
}
/** A lazy sequence of the ranges of `findstring` in this string. */