Skip to content

Instantly share code, notes, and snippets.

View hiro-riveros's full-sized avatar
👽
Focusing

Hirochi Riveros hiro-riveros

👽
Focusing
View GitHub Profile
@hiro-riveros
hiro-riveros / indemnify.rb
Created August 27, 2018 16:09
Ruby method to indemnify chilean employees
def indemnify_employee(salary, worked_months)
return 'without indemnify' if worked_months < 12
calc_indemnify = -> (salary, worked_months) do
return salary * (worked_months.to_f / 12).ceil
end
calc_indemnify.call(salary, worked_months)
end
@hiro-riveros
hiro-riveros / closures.swift
Last active August 23, 2018 19:50
How to make closures in Swift
//: Playground - noun: a place where people can play
import UIKit
func filterGreater(closure: (Int, Int) -> Bool, numbers: [Int], value: Int) -> [Int] {
var filterNumbers = [Int]()
for num in numbers {
if closure(num, value) {
filterNumbers.append(num)
}