A list of puns related to "Eigenclass"
Just what the title says. I've read about the Eigenclass and sort of get it, but am having a hard time thinking of a scenario when you'd want to use a singleton method. Can someone please explain this to me the way you would to a 5 year old?
Say I want to define a set of methods, some public, some private, and I don't want to store any state. Seems to me that I have two options: using a module, and using an eigenclass:
# eigenclass approach
class Driving
class << self
def drive(foo)
private_method(foo)
end
private
def private_method(foo)
if foo
puts 'broom broom'
end
end
end
end
...
# in another file
Driving.drive # prints 'broom broom'
Driving.private_method # raises, saying 'private_method' does not exist
# module approach
module MDriving
module_function
def self.included(base)
raise('should not be included')
end
def drive
private_method
end
def private_method
puts 'broom broom'
end
private_class_method :private_method
end
# in another file:
MDriving.drive # prints 'broom broom'
MDriving.private_method # raises saying 'private_method' does not exist
As you can see from the module approach, I've disabled including the module into another module. The reason for this is that if I permit inclusion, the parent module will have access to the private methods, which breaks encapsulation. For example:
class Test
class << self
include MDriving # assuming that we're allowing the module to be included
def test
private_method # doesn't raise
end
end
end
The eigenclass approach may confuse the reader because the use of class
suggests we'll be instantiating objects and maintaining state, neither of which we want to do.
The module approach requires extra boilerplate: disallowing inclusion and using the private_class_method
everywhere rather than the private
keyword that you can use from within a class.
Do people have a preference for either approach? Is there something I'm missing? Thanks!
Do your worst!
It really does, I swear!
For context I'm a Refuse Driver (Garbage man) & today I was on food waste. After I'd tipped I was checking the wagon for any defects when I spotted a lone pea balanced on the lifts.
I said "hey look, an escaPEA"
No one near me but it didn't half make me laugh for a good hour or so!
Edit: I can't believe how much this has blown up. Thank you everyone I've had a blast reading through the replies π
Theyβre on standbi
Buenosdillas
Pilot on me!!
Dad jokes are supposed to be jokes you can tell a kid and they will understand it and find it funny.
This sub is mostly just NSFW puns now.
If it needs a NSFW tag it's not a dad joke. There should just be a NSFW puns subreddit for that.
Edit* I'm not replying any longer and turning off notifications but to all those that say "no one cares", there sure are a lot of you arguing about it. Maybe I'm wrong but you people don't need to be rude about it. If you really don't care, don't comment.
When I got home, they were still there.
What did 0 say to 8 ?
" Nice Belt "
So What did 3 say to 8 ?
" Hey, you two stop making out "
I won't be doing that today!
You take away their little brooms
This morning, my 4 year old daughter.
Daughter: I'm hungry
Me: nerves building, smile widening
Me: Hi hungry, I'm dad.
She had no idea what was going on but I finally did it.
Thank you all for listening.
There hasn't been a post all year!
I'm surprised it hasn't decade.
Why
Itβs pronounced βNoel.β
After all his first name is No-vac
What, then, is Chinese rap?
Edit:
Notable mentions from the comments:
Spanish/Swedish/Swiss/Serbian hits
French/Finnish art
Country/Canadian rap
Chinese/Country/Canadian rock
Turkish/Tunisian/Taiwanese rap
[Removed]
There hasn't been a single post this year!
(Happy 2022 from New Zealand)
Nothing, it just waved
Bob
Please note that this site uses cookies to personalise content and adverts, to provide social media features, and to analyse web traffic. Click here for more information.