Server Side Swift vs. The Other Guys — 1: Input
VAPOR
15320

Methods Hash#dig and Array#dig were introduced in Ruby 2.3 (as well as the safe navigation operator).

So why not just:

class InputController < ApplicationController
def input
if (second_user_id = params.dig(:users, 1, :id)).is_a?(Integer)
render json: { second_user_id: second_user_id }
else
head :bad_request
end
end
end

It took only 6ms to get a response.

Like what you read? Give Vasily Yudin a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.