Sha256: 7e6a664dabacc772d8d12ca1d407ee05d9fee6d8474e1dd7231412a3daed4aee
Contents?: true
Size: 736 Bytes
Versions: 130
Compression:
Stored size: 736 Bytes
Contents
struct SecretHandshake { var commandValue: Int var commandValues = [1: "wink", 2: "double blink", 4: "close your eyes", 8: "jump"] init(_ commandValue: Int) { self.commandValue = commandValue } var shouldReverse: Bool {return (commandValue & 16) != 0} var commands: [String] {return commandsFunc()} private func commandsFunc() -> [String] { var commands = [String]() for key in Array(commandValues.keys).sorted( by: < ) { if (commandValue & key) != 0 { commands.append(commandValues[key]!) } } if shouldReverse { return Array(commands.reversed()) } else { return commands } } }
Version data entries
130 entries across 130 versions & 1 rubygems