`
vivimusing
  • 浏览: 81126 次
  • 性别: Icon_minigender_1
  • 来自: 台州
社区版块
存档分类
最新评论

关于class<<self .... end

阅读更多
module Lib
	class<<self
		def fuc
			puts "in Lib'fuc"
			puts self
		end
	end
end
class A
	include Lib
	def self.fuc
		puts "in A'fuc"
		puts self
	end
end

Lib.fuc
A.fuc

gets

  输出结果是

in Lib'fuc
Lib
in A'fuc
A

class<<self 相当于批量定义了 def self.someMethods

分享到:
评论

相关推荐

    VB编程资源大全(英文源码 控制)

    It can post messages and recieve messages through the internet.&lt;END&gt;&lt;br&gt;8 , optiondemo.zip&lt;br&gt;This example demonstrates how to create realistic Option Buttons in Visual Basic.&lt;END&gt;&lt;br&gt;9 , mencrypt....

    VB编程资源大全(英文源码 API)

    These include a self-closing message box, and a form-centered message box.&lt;END&gt;&lt;br&gt;9 , menucol.zip&lt;br&gt;This shows how to add "columns" to your menus. An excellent example.&lt;END&gt;&lt;br&gt;10 , changeborder....

    Visual C++ 编程资源大全(英文源码 文件)

    (15KB)&lt;END&gt;&lt;br&gt;6,fileinfo.zip&lt;br&gt;CFileInfoArray: A class for gathering file information recursively through directories(63KB)&lt;END&gt;&lt;br&gt;7,self_extractor.zip&lt;br&gt;A class that allows you to create self ...

    基于Python实现RSA 加密和解密算法【100011713】

    key_pair = rsa.generate_private_key背部end=default_backend(), public_exponent=65537, key_size=2048) public_key = key_pair.public_key() ``` - 加密和解密: ```python from cryptography.hazmat....

    python烟花代码.doc

    self.turtle.end_fill() def explode(self): for _ in range(random.randint(10, 20)): particle = Particle(self.x, self.y, self.color) particle.draw() ``` - `__init__`方法:初始化烟花的位置、大小和...

    环形数组的python实现.zip

    end = (self.front + self.count - 1) % self.size while start != end: print(self.array[start], end=" ") start = (start + 1) % self.size print(self.array[end]) ``` 在上述代码中,`enqueue` 方法用于...

    Python编程之gui程序实现简单文件浏览器代码

    self.dirs.bind('&lt;Double-1&gt;', self.setDirAndGo) self.dirsb.config(command=self.dirs.yview) self.dirs.pack(side=LEFT, fill=BOTH) self.dirfm.pack() self.dirn = Entry(self.top, width=50, textvariable...

    写公共函数文件,要使用到类,将类传参进来.rb

    puts "Hello from #{self.class.name}" end end end end # 另一个文件,例如main.rb,导入并使用公共函数 require_relative 'lib/utility_module' # 创建一个名为Person的类 class Person end # 将Person类...

    用Python绘制高级爱心图形.docx

    self.turtle.end_fill() self.turtle.penup() def move(self): if self.y &lt; 300: self.y += self.speed self.x += self.speed * math.sin(math.radians(self.y % 360)) self.draw() self.turtle.update() ...

    beautifulsoup4-4.3.0

    def handle_endtag(self,tag): if tag==self.processing: #self.log.error('3 %s', str(tag)+':'+str(self.getdata())) #self.log.error('3 map_table=%s', self.map_table) self.processing=None def get...

    链表类的封装(功能:排序,插入,删除)

    if position &lt; 1 or position &gt; self.length() + 1: print("Invalid position") return new_node = ListNode(data) if position == 1: new_node.next = self.head self.head = new_node else: current = ...

    cxGrid右键菜单

    {$IFEND} uses ABPubListBoxItemU,ABPubMemoItemU, ABcxGridPopupMenu_FuncU, ABcxGridAndcxTreeViewSearchU, ABcxGridPopupMenu_FigureU, ABcxGridPopupMenu_ColorSetupU, ABcxGridPopupMenu_AddColumU, ...

    rails _sunspot 学习笔记

    &lt;p&gt;No results found.&lt;/p&gt; &lt;% end %&gt; &lt;/div&gt; ``` 在这个视图文件中,我们首先检查是否存在搜索结果。如果有结果,我们会根据是否存在分面搜索的结果来显示不同的内容。此外,还会根据模型的名称显示不同类型的...

    链表-使用Python基于链表实现栈数据结构.zip

    def insert_at_end(self, data): if self.is_empty(): self.insert_at_beginning(data) else: current = self.head while current.next: current = current.next new_node = ListNode(data) current.next =...

    学生上课传输文件系统程序

    unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, FileCtrl, IdBaseComponent, ShellApi,IdComponent, IdIPWatch, ...end.

    FlexGraphics_V_1.79_D4-XE10.2_Downloadly.ir

    in FlexEditSE captures focus on self. - FIX Invalid arc size calculation when flex-control's size changes via DocRect property. Absence of the UpdateCounter checking brings to reccurent scaling. ...

    基于python实现串口GUI编程源码

    self.text_area.insert(tk.END, f"接收:{received}\n") self.text_area.yview(tk.END) self.text_area.config(state='disabled') self.root.update_idletasks() if __name__ == "__main__": root = tk.Tk() ...

    python 最牛的解析html的方法

    def handle_endtag(self, tag): if self._level_stack and tag in self.selected and tag == self._level_stack[-1]: self._level_stack.pop() def handle_data(self, data): for key in codemap.keys(): ...

    使用opengl绘制框选动画,鼠标按下且拖动时生成一个矩形框,鼠标松开时,矩形框消失

    class RectPainter: def __init__(self): # super().__init__() self.start_x = 0 self.start_y = 0 self.end_x = 0 self.end_y = 0 self.clear_flag = False def prepare(self): vshader_src = """ #...

    The Art of Assembly Language Programming

    You are visitor as of October 17, 1996.&lt;br&gt;The Art of Assembly Language Programming&lt;br&gt;&lt;br&gt;Forward Why Would Anyone Learn This Stuff?&lt;br&gt;1 What's Wrong With Assembly Language&lt;br&gt;2 What's Right With ...

Global site tag (gtag.js) - Google Analytics