The defined? keyword in Ruby. An overview of the defined? keyword…

Here, we can see that defined? handles a maximum of cases. But some cases are more relevant than others. For example, let’s see how the resolv-replace library — available in the Ruby Standard Library — takes advantage of this keyword to handle a really “tricky” case.defined? in the context of resolv-replaceThis library simply monkey-patches (IP|TCP|UDP|SOCKS)Socket classes provided by the socket library to use the Resolv DNS resolver.In the case of SOCKSSocket, the monkey-patching only intervenes when the Ruby interpreter is compiled with the --enable-socks flag. So let’s see how the resolv-replace library handles this tricky case.
The defined? keyword in Ruby. An overview of the defined? keyword… #ruby #rubydeveloper #rubyonrails https://www.rubyonrails.ba/single/the-defined-keyword-in-ruby-an-overview-of-the-defined-keyword

Nezir Zahirovic

Contractor Ruby On Rails (8+ years) / MCPD .Net / C# / Asp.Net / CSS / SQL / (11 years)

related articles