Redirects and one-way differences, use cases?

Ruby Forwardableand stdlib are SingleForwardablealmost the same, see this meaning to compare their code.

The documentation SingleForwardablesays:

SingleForwardablecan be used to configure delegation at the object level. It SingleForwardablecan also be used to configure delegation for Classor Module.

But I see that Forwardableit can also do the job.

What is their main difference and, most importantly, what are their use cases? Thank.

+4
source share
1 answer

For me it seems almost identical. The only real difference that I see is

  module_eval(str, __FILE__, line_no)

added to Forwardable.

, SingleForwardable Forwardable - . Forwardable .

, SingleForwardable debug, , Forwardable. , SingleForwardable , , .

, .

+3

Source: https://habr.com/ru/post/1546513/


All Articles