On Thursday, December 5, 2019 at 6:05:25 AM UTC-8, Petr Kaleta wrote:
>
> Hi everyone,
> I've found this in Sequel source
>
> (
>   # Exception class raised when +require_modification+ is set and an 
> UPDATE or DELETE statement to modify the dataset doesn't
>   # modify a single row.
>   NoExistingObject = Class.new(Error)
> ).name
>
>
> and I am just curious if there's any benefit compared to standard
>
> class NoExistingObject < Error; end
>

>From the commit message that added this:

    Use Class.new instead of empty exception classes

    According to Eric Wong, Class.new instead of creating an empty
    class saves about 200 bytes per class by avoiding creation of
    a class definition scope.

    However, if you don't create a class definition scope, then
    the class's name is not set immediately, it will be delayed until
    runtime and cached on the first call to name.  So call name on all
    of the classes to ensure the name is cached.

Thanks,
Jeremy

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/087fa98c-f2ee-4d02-b166-7a5330144324%40googlegroups.com.

Reply via email to