@@collinjilbert I'm back end developer and i was searching videos to be better and create clean code and organize my code. Your videos help me a lot with this. Thank you Collin.
If you extend self in the module and then include (not extend) that module in another class, then the methods in the module will be available to instances of the including class while still allowing the methods in the module to be callable on the module itself. Example: module Foo extend self def say_hello p "Hello, world" end end Foo.say_hello #=> "Hello, world" class Bar include Foo end Bar.new.say_hello #=> "Hello, world" Alternatively, if you extend the module inside another class, then the methods will be available to the class itself just as they are on the module. class Baz extend Foo end Baz.say_hello #=> "Hello, world" Hope that helps!
I never though someday I would see Adam Driver teach ruby modules and yet here we are...
thanks for the amazing content and keep up the good work!
Thanks a bunch!!! lol
Didn't know Kylo was into programming.
I was gonna say 😆
I'm pretty good with a force push
@@collinjilbert 😆👍
Great video!
Regards from Mérida, Yucatán, México.
Thank you so much, Cristian! I appreciate it very much.
@@collinjilbert I'm back end developer and i was searching videos to be better and create clean code and organize my code. Your videos help me a lot with this.
Thank you Collin.
@@cristianchable7739 Awesome! I'm glad you found it helpful/useful. Thank you so much for watching!! :)
Great tutorial, I got inspired and learned stuff. 👍
That's awesome! Glad to hear both of those things! Thanks for watching! :)
couldn't blink my eyes while watching your videos .... just too busy to learn new things
I'm not sure if this is a good comment or not lol
i got a little confused from the example, if i want to modularize instance methods would it be possible?
If you extend self in the module and then include (not extend) that module in another class, then the methods in the module will be available to instances of the including class while still allowing the methods in the module to be callable on the module itself. Example:
module Foo
extend self
def say_hello
p "Hello, world"
end
end
Foo.say_hello
#=> "Hello, world"
class Bar
include Foo
end
Bar.new.say_hello
#=> "Hello, world"
Alternatively, if you extend the module inside another class, then the methods will be available to the class itself just as they are on the module.
class Baz
extend Foo
end
Baz.say_hello
#=> "Hello, world"
Hope that helps!
Kylo, Undercover developer
Didn't know it, thanks
You bet! Thanks for watching!
I didnt know