`
lfx_cool
  • 浏览: 67800 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

include and extend

 
阅读更多
Correct Understand:
"extend" adds methods from a module into a class as class methods.
"include" adds methods from a module into a class as instance methods.


It is quite easy to demonstrate this actually.


module SomeModule
  def hi
    puts "hello"
  end
end

class ExtendSample
  extend SomeModule
end

ExtendSample.hi

class IncludeSample
  include SomeModule
end

IncludeSample.new.hi
分享到:
评论

相关推荐

    uml用例试图详解

    5. **扩展和包含关系(Include and Extend)** - **包含(Include)**:当多个用例共享相同的行为时,可以使用包含关系来减少冗余。一个用例可以包含另一个用例的行为,被包含的用例通常表示为一个子任务。 - **...

    英文原版-Learning The Vi And Vim Editors 7th Edition

    such as multi-window editing, how to write both interactive macros and scripts to extend the editor, and power tools for programmers — all in the easy-to-follow style that has made this book a ...

    Microsoft SharePoint 2010 and Windows PowerShell 2.0

    - **Creating Custom PowerShell Snap-Ins**: Snap-ins provide a way to extend the PowerShell environment with additional cmdlets and functionality. This section explains how to create a custom snap-in ...

    osgi.enterprise-6.0.0

    to tailor and extend the OSGi framework to address information technology software infrastructure use cases found in enterprise scenarios. The EEG technical areas of concern include: • Scaling, ...

    Bootstrap Essentials (pdf)

    As the number of Internet users on mobile devices is growing every ... You will also be able to build and compile Bootstrap from the source code, and nally customize and extend to suit your requirements.

    tabu search fundmentals and uses ---fred glover

    As researchers and practitioners continue to refine and extend the capabilities of TS, it is poised to play an even more critical role in addressing real-world challenges in various fields.

    Programming+Python,+4th+Edition(2/2)

    If you’ve mastered Python’s fundamentals, you’re ready to ... More ways to apply Python: Implement data structures, parse text-based information, interface with databases, and extend and embed Python

    Programming+Python,+4th+Edition(1/2)

    If you’ve mastered Python’s fundamentals, you’re ready to ... More ways to apply Python: Implement data structures, parse text-based information, interface with databases, and extend and embed Python

    Pro AngularJS

    The most important features are given a no-nonsense in-depth treatment and chapters include common problems and details of how to avoid them. What you'll learn •Gain a solid architectural ...

    Qt Virtual Keyboard 官方示例代码

    Support for most common input languages, with possibility to easily extend the language support. Left-to-right and right-to-left input. Hardware key support for 2-way and 5-way navigation. Handwriting...

    visual c++2008入门经典 高清pdf电子书

    ❑ You have some knowledge of C++ and you want to extend your C++ skills to include C++/CLI. ❑ You are a newcomer to programming and sufficiently keen to jump in the deep end with C++. To be ...

    Pro Angular [ Adam Freeman, 2017, PDF]

    The most important features are given a no-nonsense in-depth treatment and chapters include common problems and details of how to avoid them. What you’ll learn Gain a solid architectural ...

    Amplify Shader Editor 1.5.5.zip

    While in the current version you can create and extend Surface Shaders, upcoming updates will include dozens of additional shader types, custom lighting models and extended options to help unleash ...

Global site tag (gtag.js) - Google Analytics