Skip to content

Instantly share code, notes, and snippets.

@WhereIsX
Created April 29, 2021 21:17
Show Gist options
  • Save WhereIsX/629e3c6785569c70c70a016f27d36e98 to your computer and use it in GitHub Desktop.
Save WhereIsX/629e3c6785569c70c70a016f27d36e98 to your computer and use it in GitHub Desktop.
crystal compiler can't deduce that all values of uint is handled
arg_size = args.size.to_u
# wrong number of arguments
if arg_size == 0 || arg_size > 2
next "wat. try #{Command.all["!feed"].description}"
end
ducky = Ducky.find_by(username: args.first.downcase)
# cant find ducky to feed
if ducky.nil?
next "hmm.. #{args.first} should !start_record to recieve feed"
end
case arg_size
when 1
points = 10
# give ducky the default amount of points
when 2
points = args.last.to_i { 0 }
# try* to parse to int, if not default to 0
end
points.not_nil!
# we have covered all possible values for u_int
# (see line 17, 27-34)
# not sure if this is the best way to handle...
if points.zero
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment