Skip to content

Instantly share code, notes, and snippets.

Avatar

Jung Kim godrm

  • Codesquad
  • Seoul, KOREA
  • Twitter @godrm
View GitHub Profile
@godrm
godrm / pascalTriangle.swift
Created Jul 11, 2017
Functional Pascal Triangle
View pascalTriangle.swift
func makePascalTriangle(numOfRows: Int) -> ([[Int]]) {
func getNextRow(_ arr: [Int]) -> [Int] {
let a = zip([0]+arr, arr+[0])
return a.map({
(e: (Int, Int)) -> Int in
e.0 + e.1
})
}
func helper(_ countDown: Int, results: [[Int]]) -> (Int, [[Int]]) {
View guard let shadow.swift
var x : Int? = 10
//arguments
func foo(arg : Int?) {
guard let arg = arg else {
return
}
print(arg)
}
foo(arg:x)
View PipeOperator.swift
//
// main.swift
// HelloOperator
//
// Created by JK on 09/04/2018.
// Copyright © 2018 JK. All rights reserved.
//
import Foundation
View customview.swift
//
// MyCustomView.swift
// CustomView
//
// Created by JK on 12/04/2018.
// Copyright © 2018 JK. All rights reserved.
//
import UIKit
View animation_example.swift
//
// ViewController.swift
// HelloAnimation
//
// Created by JK on 19/04/2018.
// Copyright © 2018 JK. All rights reserved.
//
import UIKit
View customer-order.swift
class Entity {
var name : String = ""
init(name : String) {
self.name = name
}
}
class Order {
private (set) var id = UUID()
private (set) var date = Date()
View customer-class.swift
class Customer :
Entity,
AggregateProtocol
{
private (set) var id : UUID
private (set) var email : String
private var orders : Array<Order>
//...중간생략...
View CustomerOrderController.swift
class Product {
private var id = UUID()
}
class CustomOrderRequest {
private (set) var products = [Product]()
}
protocol OrderCommand {
View AddCustomerOrderCommandHandler.swift
protocol CustomerRepositoryProtocol {
}
protocol ProductRepositoryProtocol {
}
struct ConversionRate {
var fromCurrency : String
View CustomerOrderController-wrong.swift
class CustomerOrderController {
private (set) var orderService : OrderService
init(service: OrderService) {
self.orderService = service
}
}