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
let otherTableau: Array<(Int, String)> = [(1,"a"),(2,"b"),(3,"c"),(4,"d")] | |
let mean = otherTableau.map { tuple -> Int in | |
return tuple.0 | |
} | |
/* | |
On peut aussi écrire le map de mean de cette facon, pour raccourcir l'écriture | |
"$0" est "le premier argument" |
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
/* | |
In response of Tom Lokhort's article. | |
A third alternative: alternative 2 under steroïds | |
--- | |
Source: http://tom.lokhorst.eu/2017/07/strongly-typed-identifiers-in-swift | |
*/ | |
struct GenericIdentifier<T>: RawRepresentable, Hashable, Equatable { | |
let rawValue: String |
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 Numeric where Self: Comparable /* NORMALIZER */ { | |
/// normalize the current value between a min and a max interval, by adding optionaly a value. this works just like the compass normalization. for Ex, 357°, by adding +4 became 1° for [0 - 360] interval | |
/// | |
/// - Parameters: | |
/// - value: the value to add | |
/// - min: the minimum interval | |
/// - max: the maximum interval | |
/// - Returns: the new, transformed and normalized value |
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
enum Restaurant: RawRepresentable { | |
typealias RawValue = Array<Int> | |
case toto | |
case tata | |
var rawValue: Array<Int> { | |
switch self { | |
case .tata: |
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
/// **From App to SDK(system)** | |
/// | |
/// Give informations thanks to user interaction | |
/// Called by the app, when user interacts about routing or location stuff | |
/// | |
/// `[App].call(sdkSystemDatasource.function(params))` | |
protocol PositionHelperDatasource { | |
/// Call this datasourced-function when a routing or a re-position is asked by the user |
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
/** | |
* Copyright (c) 2017 Razeware LLC | |
* | |
* Permission is hereby granted, free of charge, to any person obtaining a copy | |
* of this software and associated documentation files (the "Software"), to deal | |
* in the Software without restriction, including without limitation the rights | |
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
* copies of the Software, and to permit persons to whom the Software is | |
* furnished to do so, subject to the following conditions: | |
* |
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 NSObject { | |
private enum SetValuableErrorType: Error, CustomStringConvertible { | |
case unknown(key: String, type: NSObject) | |
var description: String { | |
switch self { | |
case .unknown(key: let k, type: let t): | |
return "Unknown parameters \(k) for object typped \(String(describing:t))" | |
} |
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
import Foundation | |
import Result | |
import RxSwift | |
enum ResponseErrorType: Error, CustomStringConvertible { | |
case technical | |
case notFound | |
case other(message: Array<String>) | |
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
// | |
// Theme.swift | |
// juliengdt | |
// | |
// Created by julien.GOUDET on 26/10/2015. | |
// Copyright © 2015 julien.GOUDET. All rights reserved. | |
// | |
import Foundation | |
import UIKit |
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
/* 1 - When your backend dev doesn't know how to REST*/ | |
let backEndLOL: [[String: String]] = [["Key":"CAPACITY","Value":"323"],["Key":"rate","Value":"3.00"]] | |
// Okay let's do his/her job | |
extension Collection where Iterator.Element == [String: String] { | |
var trueFuckingJson: [String: String] { | |
let tupleArray: [(String, String)] = self.map{ dict -> [String: String] in |