Skip to content

Instantly share code, notes, and snippets.

private func formatIP(with text: String) -> String {
let divider = "."
var ipBlocks = text.components(separatedBy: divider)
let lastBlock = ipBlocks.popLast() ?? ""
guard let number = Int(lastBlock), number > 0 else {
if let lastSymbol = text.last,
String(lastSymbol) == divider,
let lastIpBlock = ipBlocks.last,
!lastIpBlock.isEmpty {
@torburg
torburg / CarGist
Last active August 27, 2019 22:27
test gists
class Car {
private var position = (x: 0, y: 0)
public func execute(_ move: Go) {
switch move.direction {
case "right":
self.position.x += move.distance!
case "left":