lundi 27 avril 2020

how to pass the return value of function with & operator in ruby?

I came across following code snippet in ruby, where the safe navigation operator is used to call a second method, in the example below, does the response we get from Excon.get call passed to the process_json automatically. in the function definition of process_json ,there is no parameter being passed. I am not sure how this might work.

class Client
   API_ENDPOINT = 'https://api.twitter.com'

   class << self
      def call()
       Excon.get(API_ENDPOINT)&.process_json
      end

      def process_json
         //process json response
      end
    end
end

Aucun commentaire:

Enregistrer un commentaire