- Elvis operator
val data = response?.body
val title: String = data?.title ?: 'Page'
- Strings templates
android { | |
aaptOptions { | |
noCompress "tflite" | |
noCompress "lite" | |
} | |
} |
import Foundation | |
struct Linguistic { | |
typealias LinguisticTag = (token: String, tag: String) | |
static func tags(text: String, range: NSRange? = nil, language: String = "en") -> [LinguisticTag] { | |
let options: NSLinguisticTaggerOptions = [.OmitWhitespace, .OmitPunctuation, .JoinNames] | |
let schemes = NSLinguisticTagger.availableTagSchemesForLanguage(language) |
This proposal seeks to provide more lenient subscript
import Foundation | |
struct Math { | |
static func standardDeviation(values: [Double]) -> Double { | |
let squaredAvgDiff = values.map { pow($0 - average(values), 2)} | |
let sum = squaredAvgDiff.reduce(0) {$0 + $1} | |
return sqrt(sum / Double(values.count)) | |
} | |
protocol StringType {} | |
extension String: StringType {} | |
extension Optional where Wrapped: StringType { | |
var something: Int { | |
switch self { | |
case .None: return 10 | |
case .Some(_): return 20 | |
} | |
} |
from django.core.files.storage import default_storage | |
from django.core.files.base import ContentFile | |
import os | |
import uuid | |
import urllib | |
def save_image_from_url(url): | |