Sha256: 497309da49aafbdb0d3e9400c80bb871c082945be9b7e08f2d1c6fd2f2b7df20
Contents?: true
Size: 767 Bytes
Versions: 66
Compression:
Stored size: 767 Bytes
Contents
use "regex" // Not the best example. Will refactor when I grok the type system better. class Bob let _default: String new create() => _default = "Whatever." fun apply(phrase: String): String ? => if loud(phrase) then "Whoa, chill out!" elseif question(phrase) then "Sure." elseif silent(phrase) then "Fine. Be that way!" else _default end fun loud(phrase: String): Bool ? => (Regex("[A-Z]").eq(phrase)) and (phrase == phrase.upper()) fun question(phrase: String): Bool => let rephrase: String box = consume phrase rephrase.reverse().at("?",0) fun silent(phrase: String): Bool ? => let rephrase: String box = consume phrase (rephrase.size() == 0) or Regex("^\\s+$").eq(rephrase)
Version data entries
66 entries across 66 versions & 1 rubygems