ChanServ changed the topic of #crystal-lang to: The Crystal programming language | https://crystal-lang.org | Fund Crystal's development: https://crystal-lang.org/sponsors | GH: https://github.com/crystal-lang/crystal | Docs: https://crystal-lang.org/docs | Gitter: https://gitter.im/crystal-lang/crystal
Starfoxxes has quit [*.net *.split]
Starfoxxes has joined #crystal-lang
straight-shoota has quit [Ping timeout: 248 seconds]
straight-shoota has joined #crystal-lang
_whitelogger has joined #crystal-lang
jmdaemon has joined #crystal-lang
notzmv has quit [Ping timeout: 245 seconds]
_ht has joined #crystal-lang
notzmv has joined #crystal-lang
uncomfy has joined #crystal-lang
repo has quit [Ping timeout: 260 seconds]
jrayhawk_ is now known as jrayhawk
repo has joined #crystal-lang
jrayhawk has quit [Server closed connection]
jrayhawk has joined #crystal-lang
zeithan has joined #crystal-lang
<zeithan> Hi there, apologies if my question is something super obvious on the typed world
<zeithan> I have an endpoint that, depending on a count parameter given to it, the response is either a json object or an array of json objects.
<zeithan> I call it more or less like this:
<zeithan> ```
<zeithan> res = Client.get("/fishes/random", params: params)
<zeithan> if params.fetch("count", 1) > 1
<zeithan>  Array(Full).from_json(res)
<zeithan> else
<zeithan>  Full.from_json(res)
<zeithan> end
<zeithan> ```
<zeithan> Since requesting a higher count is kind of a rare thing to do, I was wondering how I could keep an api where I can do the following:
<zeithan> ```
<zeithan> bounty = Fishing.random
<zeithan> bount.name
<zeithan> bounty.size
<zeithan> bounties = Fishing.random(count: 2)
<zeithan> bounties[0].name
<zeithan> I figured out a saner solution, create a separate method for random with more than one count... so random and multi_random or something like that. Keep it simple
uncomfy has quit [Remote host closed the connection]
_ht has quit [Remote host closed the connection]
repo has quit [Ping timeout: 246 seconds]
repo has joined #crystal-lang
notzmv has quit [Ping timeout: 255 seconds]