Comprehensive Guide to Modules in Ruby 3

Ғылым және технология

Ruby modules can appear to be very similar to Ruby classes. After going through this you'll be able to:
- Understand the difference between Classes and Modules in Ruby
- Build out Ruby modules
- Work with nested modules
- Combine Classes and Modules
- See how modules can be used in large-scale, production Rails applications
Source code:
github.com/jordanhudgens/ruby...

Пікірлер: 16

  • @Aaronmoreno
    @Aaronmoreno2 жыл бұрын

    seriously some of the best teaching on ruby I've found. So thankful

  • @JamesJSwiftJay
    @JamesJSwiftJay2 жыл бұрын

    Thanks for explaining the ruby nested stuff, it's been very helpful to try and understand it. Something I didn't know Ruby had was anonymous classes which is pretty interesting and cool. Great video and great explanation.

  • @Awesomekid2283
    @Awesomekid2283 Жыл бұрын

    Is the reason for adding the nested class so you can create private methods? I can't really see what value the nested class adds other than being able to make methods private. If you didn't need the private method would it work to just define the function in the nested modules directly and skip the nested class or is the nested class important for some other aspect that I'm not understanding?

  • @udonwadon2045
    @udonwadon20452 жыл бұрын

    I don't understand why you used a class like that inside a module. What would be different if you created an actual class?

  • @ppavelcars
    @ppavelcars3 жыл бұрын

    Thank you, Jordan for the great explanation! First I have got "private method `tax_rate' called for Sale::FormBuilder:Module (NoMethodError)" since I had ruby 2.6.0 version After update to 3.0.1, it starts working

  • @edutechional

    @edutechional

    3 жыл бұрын

    Nice job working through it, and yes, this implementation is specific to Ruby 3

  • @alex_ventura
    @alex_ventura2 жыл бұрын

    Jordan, this is a really helpful example that made me thought a couple of places where I can implement this in my project. Thanks for sharing! I was wondering, how do you run Ruby inside VIM?

  • @jahjae
    @jahjae2 жыл бұрын

    Thank for Teaching

  • @chris_zou
    @chris_zou2 жыл бұрын

    Would be helpful to explain what advantages does it have to extract code to modules(and then define an anonymous class inside them) over extracting code to classes.

  • @kirindev
    @kirindev6 ай бұрын

    thank you.

  • @je9625
    @je96253 жыл бұрын

    Nice. Manipulating classes and making data available between them is one of the difficult things in ruby. This example will work for Ruby 2 as well, wont it ?

  • @edutechional

    @edutechional

    3 жыл бұрын

    I'm glad that you found it helpful! And yes, this is the same syntax for 2 and 3

  • @Xlorate
    @Xlorate5 ай бұрын

    I don't get any results

  • @Tuanjizz
    @Tuanjizz2 жыл бұрын

    this did not make sense to me at all unfortunately

  • @arnoudrattink1572
    @arnoudrattink1572 Жыл бұрын

    Using expressions like 'self.method' is pointless (in general at least) in ruby as it is equivalent to 'method'. It just makes it very confusing. Also you never actually explain the difference between a class and a module.

  • @jake9340

    @jake9340

    5 ай бұрын

    No actually "def self.method" means it is a class method while "def method" is an instance method

Келесі