Performance Let's say we want to get the first element in type Optional U in a array of type [T], T may or may not be type casted into U what will you do? 1. [T].first.flatmap{$0 as? U} 2. [T].flatmap{$0 as? U}.first Which
How I hack Pacific Coffee and get free drinks( a lot of)? First of all. The story bellow is done by my own payment as it's an experiment. Also it just work. Also, I will provide a very simple solution for such system. Please don't miss it. The story began in an evening, I went to Pacific Coffee
How to make a Message framework? Beginning and planing > Let's make a Message framework and do some practice on architecture. What we will cover in this series? * Planing and architecture of a framework * Kick start a project * Dirty work of setting up a CI * Make a Messaging framework Planing We are going to write an open
Throw inside a do block and catch it back in Swift? Yes Lazy forks, it's just simple topic, but I did the experiment for you: enum SomeError: Error { case notBig case veryBig } func someErrorFucntion() { do { throw SomeError.veryBig } catch { print(error.localizedDescription) } } someErrorFucntion() // And it will print veryBig!!
How I use gyb to achieve a more flexible localization in Swift Localization in iOS is so simple by using system provided mechanism. But it can be a nightmare if you want to achieve a more flexible goal with a so far convenient way to access. Compare to lots of solution around, I decide to use gyb to make my baby work
Don't write Swift 3 on your "wish list" I've been recently invited by many of company those who need to find a right iOS developer. The interesting part is, in almost all of their skill lists, they all want a swift 3 experiences, which, lead me to a very confusing thought, why would they ask this
Fewer "guard" more flatMap Swift's guard syntax is good, I admitted. But it's not always the best choice in some cases. Let's consider: something.callback() { someOther:SomeOther? in guard let someOther = someOther else { return } functionTakeSomeOther(someOther) } Indeed, "optional chaining" provide us a more convenience way to
你 老 師 不明白,不明白那些數學老師是怎麼想的,竟然會被學生問至啞口無言,什至失去理智以權力解決問題。 為什麼,為什麼在學生挑戰你學數學有什麼用時,每每只懂得逃避或者轉移焦點作獲取成績這類導人說出I don't give it a fxxk 的導向? 學數學的"作用"不是很大嗎? 數學教你的,是如何面對一個看完題目已想詛咒出題者的問題時,將一個貌似對自己能力無解的大問題時,保持冷靜,保持思考解決方法,分析,分拆成一個個自己有能力處理的小問題的技巧。 這正正是一套如何在這個不知所謂的社會正確地生存下去所必備的能力。何況這更是一個相對具體而有效的訓練方法啊!但是,在你的學習生涯中,有多少個"老師"嘗試過讓學生有機會去"知道"這點?卻在學生"似乎用這點攻擊"時紅眼。 難道連你也對數學失去信心?還是你在裝作無力或是放棄思考。可想想,它,數學,
我是石頭 倒下的巨人 是石頭做的 他從沒當自己是英雄 他沒有過去 但他有名字 他不是聖靈 卻很多人祈求他的祝福 世界最偉大的藝術家創造了他 他曾有最完美藝術品的美喻 但他自己不懂 他只懂自己沒有經歷 自己沒有感覺 自己沒有生活 "我曾是路童的蔭,我只是石頭" Original post from my previous site: http://povoq.blogspot.com/2009/10/blog-post.html