Skip to content

Instantly share code, notes, and snippets.

View boominadhaprakash's full-sized avatar

Boominadha Prakash boominadhaprakash

  • Sonata Software Ltd
  • Bangalore
View GitHub Profile
@boominadhaprakash
boominadhaprakash / gist:ff1ab5fe5141d02a1d875a93d28d3dd1
Last active December 6, 2017 08:44
Remove duplicates from Array of Dictionaries
var dict:[[String:String]] = [["name":"a"],["name":"b"],["name":"a"]]
let filteredDict = filter(dict)
func filter(_ arrayOfDicts:[[String:String]]) -> [[String:String]] {
var filteredDict = [[String:String]]()
var filteredName = [String]()
for d in arrayOfDicts {
if let name = d["name"], !filteredName.contains(name) {
filteredDict.append(d)
@boominadhaprakash
boominadhaprakash / Higher_Order_Functions-I.swift
Created December 11, 2017 18:01
Removing duplicates from the ArrayofObjects using Higher Order functions
let arrayOfDict:[[String:String]] = [["name":"a"],["name":"b"],["name":"a"]]
var filteredDict = [[String:String]]()
var filteredName = [String]()
arrayOfDict.map{dict in
if !(filteredName.contains(dict["name"]!)) {
filteredDict.append(dict)
filteredName.append(dict["name"]!)
}
}
struct RgbToHex: OptionSet {
let rawValue: Int
func convertRGBToHex(r: RawValue, g: RawValue, b: RawValue) -> String {
return String(format: "%X", (r << 16 | g << 8 | b))
}
}
let hex = RgbToHex().convertRGBToHex(r: 240, g: 200, b: 100)
print(hex)
import Foundation
import UIKit
struct StoryboardIdentifiers {
static let ViewController1 = "ViewController1"
static let ViewController2 = "ViewController2"
static let ViewController3 = "ViewController3"
static let ViewController4 = "ViewController4"
static let ViewController5 = "ViewController5"
static let ViewController6 = "ViewController6"