I found a lot of time waste in reading max(min(_, _), _)
, trying to reduce pain. So found this a easy way think in OOP, but I had a hard time naming the method, can AnyOne help me?
let variable = 3
let afterValue = max(2, min(30, variable))
protocol Nibed { | |
static func nib() -> UINib | |
static var id:String {get} | |
} | |
extension Nibed where Self: UITableViewCell{ | |
static func nib() -> UINib { | |
return UINib(nibName: id, bundle: nil) | |
} | |
static var id:String { |
public class Hello1 | |
{ | |
public static void Main() | |
{ | |
- System.Console.WriteLine("Hello, World!"); | |
+ System.Console.WriteLine("Rock all night long!"); | |
} | |
} |
let foo = 'bar' | |
/** | |
Don't worry about the code block, it will be saved as a gist with right language format, and auto embed to your post. | |
**/ |
func dprint(_ objects:Any..., separator: String = " ", terminator: String = "\n",file:String = #file,line:Int = #line, function:String = #function){ | |
#if DEBUG | |
print((file).split(separator: "/").last!,line.description + ":",function) | |
print("🦑 Debug info: \n\t", terminator: "") | |
for i in objects{ | |
print(i, separator: "", terminator: separator) | |
} | |
print(terminator) | |
#endif | |
} |
class TheCell:UITableViewCell,Nibed{ | |
... | |
} |
public class Hello1 | |
{ | |
public static void Main() | |
{ | |
- System.Console.WriteLine("Hello, World!"); | |
+ System.Console.WriteLine("Rock all night long!"); | |
} | |
} |
let foo = 'bar' | |
/** | |
Don't worry about the code block, it will be saved as a gist with right language format, and auto embed to your post. | |
**/ |
func fib(_ n: Int) -> Int { | |
guard n > 1 else { return n } | |
return fib(n-1) + fib(n-2) | |
} |
//main | |
let fibonacci = makeFibonacci() | |
fibonacci(10) | |
fibonacci(5) | |
fibonacci(2) | |
fibonacci(3) |