This file contains 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
<>, both not included in range, | |
<=>, both included | |
<==, left not included, | |
==> right not included | |
infix operator <> {} | |
infix operator <=> {} | |
infix operator ==> {} | |
infix operator <== {} |
This file contains 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
func ~= <T:Comparable>(lhs:T,rhs:(T,T)) -> Bool{ | |
if lhs < rhs.0{ | |
return false | |
} | |
if lhs > rhs.1{ | |
return false |
This file contains 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 Int { | |
/// Construct an instance that approximates `other`. | |
public init(_ other: Float) | |
/// Construct an instance that approximates `other`. | |
public init(_ other: Double) | |
/// Construct an instance that approximates `other`. | |
public init(_ other: Float80) | |
} |
This file contains 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
//Number classes use initializers, that take in other number types to convert between types | |
//Essentially this is what is going on: | |
//`Int(4.5)` ~is just this~ `Int.init(4.5)` | |
//Which is using `init(_ value:Double)` definid with in the `Int` class | |
//Using this knoledge we can optimize our conersions with pattern matching | |
import CoreGraphics //For CGFloat |
This file contains 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
func ?= <T:IntNumberConvertible, U:NumberConvertible>(var lhs: T, rhs: U) -> T{ | |
print("INTNUMBER") | |
let max :Double = T.max.convert() | |
let test :Double = rhs.convert() | |
if test > max{ | |
assert(false, "Conversion Loss") | |
} |
This file contains 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 defering{ | |
// func g <T>(T? -> T?){ | |
// | |
// } | |
var defers:[(Void -> Void)] = [] | |
func fer( df:Void -> Void){ | |
defers.append((df)); | |
} |
This file contains 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 DictionaryLiteralConvertible where Key == String, Value == AnyObject { | |
func magicFilter(){ | |
print("blah") | |
} | |
} | |
//WORKS | |
let test1 = [String : AnyObject]() | |
test1.magicFilter() |
This file contains 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 func findCustomFonts(){ | |
for family in UIFont.familyNames() | |
{ | |
NSLog("%@", family as! String); | |
let fontNames = UIFont.fontNamesForFamilyName(family as! String); | |
fontNames.map{ | |
println("\($0)") | |
} |
This file contains 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
/// var num:Double = 12; | |
/// var num2:Float = num.f; | |
/// var num3:CGFloat = num.c; | |
/// var num4:Int = num.i; | |
/// var num5:Double = num2.d; | |
import UIKit; | |
extension Double{ | |
var c:CGFloat{ |
NewerOlder