This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| inline fun <T>tryOrNull(action: () -> T): T? { | |
| var ret: T? | |
| try { | |
| ret = action() | |
| } catch (e: Exception) { | |
| ret = null | |
| // TODO: log error | |
| } | |
| return ret | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Foundation | |
| infix operator .. | |
| func ..<T:AnyObject>(lhs: T, rhs:(T) -> Void) -> T { | |
| rhs(lhs) | |
| return lhs | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import UIKit | |
| class Foo { | |
| var bar: Int | |
| init(bar: Int) { | |
| self.bar = bar | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 1> import Foundation | |
| 2> let test = String(contentsOfFile: "/test.txt") | |
| fatal error: init(contentsOfFile:usedEncoding:) is not yet implemented: file Foundation/NSString.swift, line 1304 | |
| test: String = { | |
| _core = { | |
| _baseAddress = <extracting data from value failed> | |
| _countAndFlags = <extracting data from value failed> | |
| _owner = <extracting data from value failed> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| String(contentsOfFile: "/test.txt") | |
| /* OUTPUTS: | |
| main.swift:2:17: note: overloads for 'String' exist with these partially matching parameter lists: (_StringCore), (Character), (String.CharacterView), (_builtinUnicodeScalarLiteral: Int32), (unicodeScalarLiteral: String), (extendedGraphemeClusterLiteral: String), (stringLiteral: String), (_storage: _StringBuffer), (S), (stringInterpolation: String...), (stringInterpolationSegment: T), (stringInterpolationSegment: String), (stringInterpolationSegment: Character), (stringInterpolationSegment: UnicodeScalar), (stringInterpolationSegment: Bool), (stringInterpolationSegment: Float32), (stringInterpolationSegment: Float64), (stringInterpolationSegment: UInt8), (stringInterpolationSegment: Int8), (stringInterpolationSegment: UInt16), (stringInterpolationSegment: Int16), (stringInterpolationSegment: UInt32), (stringInterpolationSegment: Int32), (stringInterpolationSegment: UInt64), (stringInterpolationSegment: Int64), (stringInterpolationSegment: UInt), (stringInterpola |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| protocol Hook { | |
| var matchingPaths: [Int : String] { get } | |
| var matchingVars: [Int : String] { get } | |
| func match(pathComponents: [String]) -> String? | |
| } | |
| extension Hook { | |
| func match(pathComponents: [String], queryString: String) -> String? { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| scratchCanvas = document.createElement('canvas') | |
| scratchCanvas.width = size | |
| scratchCanvas.height = size | |
| scratchCtx = scratchCanvas.getContext('2d') | |
| scratchCtx.clearRect(0, 0, scratchCanvas.width, scratchCanvas.height) | |
| scratchCtx.globalCompositeOperation = 'source-over' | |
| scratchCtx.drawImage(image, 0, 0, size, size) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| queryString = (params) -> | |
| _.map params, (value, key) -> | |
| encodeURIComponent(key) + "=" + encodeURIComponent(value) | |
| .join("&").replace(/%20/g, "+") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| extension Array { | |
| func mapSome<R>(transform: T -> R?) -> [R] { | |
| return self.reduce([R]()) { | |
| if let unwrappedValue = transform($1) { | |
| return $0 + [unwrappedValue] | |
| } | |
| return $0 | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class A { | |
| let b = "TEST" | |
| var c = self.b //no error | |
| } | |
| class D { | |
| let e = "TEST" | |
| let f = self.e //error | |
| } |
NewerOlder