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

class<<self

 
阅读更多
问:
Hi
   I have code like

   class A
     class <<self
        def first
         -------
        end
        def second
          ------
         end
      end
    end

    What I understood is now the def first and second becomes class methods of class A..Am I right? Is that its only use?

Thanks in advance
Sijo

答:
Yes you understood it well, and it's its only use. You could also type:

class A
def self.first
end
end

or

class << A
def first
end
end
分享到:
评论

相关推荐

    A class of self-affine and self-affine measures

    这是一篇关于自相似测度和自仿射测度的专业文献。系统给出了自相似测度和自仿射测度的分类。

    Python类class参数self原理解析

    1.self只有在类的方法中才会有,其他函数或方法是不必带self的。 2.在调用时不必传入相应的参数。 3.在类的方法中(如__init__),第一参数永远是self,表示创建的类实例本身,而不是类本身。 4.可以把对象的各种...

    php class中self,parent,this的区别以及实例介绍

    一,this 1,要用this,你必有是一个对像的形势,不然它会报错的,Fatal error: Using $this when not in object context。2,this可以调用本类中的方法和属性,也可以调用父类...class test{ public $public; priv

    iOSputao#iOS-#[self class] 与 [super class]1

    /* For compatibility with old objc-runtime.h header *//* super_class is the firs

    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中class和instance以及self的用法详解

    今天小编就为大家分享一篇对Python中class和instance以及self的用法详解,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧

    MyFrame.class

    MyFrame.class

    Ford's ApproachTo Developing Self-Driving Vehicle

    5 Best in class partners: working with Argo AI 6 How we earn trust-Applying safety processes 7 How we earn trust-Designing for reliability 8 How we earn trust-Delivering a valuable customer experience...

    python实现飞机大战

    用python+pygame实现飞机大战,python解释器3.8,pygame==2.1.0,将环境配置完成后... if self.pos[0] &lt; self.r or self.pos[0] + self.r &gt; 400: self.speed[0] = - self.speed[0] if self.pos[1] &lt; self.r or self.p

    如家宠物网站

    xml=&lt;data&gt;&lt;config&gt;&lt;isShowTitle&gt;0&lt;/isShowTitle&gt;&lt;autoPlayTime&gt;5&lt;/autoPlayTime&gt;&lt;/config&gt;&lt;channel&gt;&lt;item&gt;&lt;link&gt;&lt;/link&gt;&lt;image&gt;images/0411412705084558.jpg&lt;/image&gt;&lt;title&gt;&lt;/title&gt;&lt;/item&gt;&lt;item&gt;&lt;link&gt;&lt;/link&gt;...

    详解Python self 参数

    我们在使用 Python 中的 方法 method 时,经常会看到 参数中带有 self,但是我们也没对这个参数进行赋值,那么这个参数到底是啥意思呢? 2、知识点 2.1 成员函数(m) 和 普通方法(f) Python 中的 “类方法” 必须有一...

    Python self用法详解

    class Person: def __init__(self): print("正在执行构造方法") # 定义一个study()实例方法 def study(self): print(self,"正在学Python") zhangsan = Person() zhangsan.study() lisi = Person() lisi.study()...

    Mix-and-Match Tuning for Self-Supervised Semantic Segmentation

    A "match" stage then forms a class-wise connected graph, which can be used to derive a strong triplet-based discriminative loss for fine-tuning the network. Our paradigm follows the standard practice...

    【金榜学案】2014版六年级英语下册 Unit 6 Don’t eat in class Section B(3a-Self C

    【金榜学案】2014版六年级英语下册 Unit 6 Don’t eat in class Section B(3a-Self Check)课件 鲁教版五四制

    Ruby self在不同环境的含义

    二、在class或module的定义中: 在class和module的定义中,self代表这个class或这module对象: Ruby代码 class S puts ‘Just started class S’ puts self module M puts ‘Nested module S::

    Device Class Definition for HID 1.11

    The Device Class Definition for HID 1.11 is intended to supplement the USB Specification and provide HID manufacturers with the information ...&gt; be self-describing to allow generic software applications

    全面理解Python中self的用法

    刚开始学习Python的类写法的时候觉得很是麻烦,为什么定义时需要而调用时又不需要,为什么不能内部简化从而减少我们敲击键盘的次数?你看完这篇文章后就会明白...&lt;class&gt; 从上面的例子中可以很明显的看出,self代表的

    luaclass:Lua 的简单类

    luaclass - Lua 的简单类Lua 中的典型 OOP 如下所示: local Class = {}function Class:new ( o ) o = o or {} setmetatable ( o, self ) self . __index = self return oendreturn Class 使用它看起来像这样: ...

    Python中的self用法详解

    在Python类中规定,函数的...类 class 中为啥用使用 self ? 在类的代码(函数)中,需要访问当前的实例中的变量和函数,即访问Instance中的: 对应的变量(property):Instance.ProperyNam,去读取之前的值和写入新的

    python基础训练题-类和方法的概念和实例 类(Class):用来描述具有相同的属性和方法的对象的集合

    类(Class):用来描述具有相同的属性和方法的对象的集合。它定义了该集合中每个对象所共有的属性和方法。对象是类的实例。 方法:类中定义的函数。 类的构造方法__init__():类有一个名为 init() 的特殊方法(构造...

Global site tag (gtag.js) - Google Analytics