亚是什么意思| 狗皮膏药是什么意思| 尿泡多是什么原因| 配裙子穿什么鞋子好看| 喉咙疼痛一咽口水就疼吃什么药| 相敬如宾是什么生肖| 锻炼pc肌有什么好处| 法兰绒是什么面料| 怀孕吃叶酸有什么用| 黄芪和什么搭配最好| 葡萄什么时候种植| 扫把和什么是一套的| 卵巢过度刺激综合症是什么| 吃木瓜有什么作用| 胃烧心是什么原因| 细菌感染吃什么药| 坎宅是什么意思| 迪根是什么药| 苦瓜和什么搭配最好| 溜肩是什么意思| 氯超标是因为什么原因| fpa是什么意思| 煞星是什么意思| 头秃了一块是什么原因| 尿毒症前兆是什么症状表现| 芒果有什么营养| 两腿抽筋是什么原因| 什么可以代替人体润滑油| 凿壁偷光形容什么| 神是什么| 血钙是什么意思| 凝血酸是什么| 孕妇感冒吃什么药| 公安局属于什么机关| 什么虫子咬了像针扎一样疼| 2b是什么意思| 鱼腥草有什么功效| 看痣挂什么科| 什么叫会车| 吃什么最容易减肥| 瑗字五行属什么| 荷花什么时候开| 口腔溃疡是缺少什么维生素| 请人帮忙用什么词| 蝌蚪吃什么| 跟腱炎什么症状| 姓贾的男孩取什么名字好| 脂肪肝吃什么食物| 吃什么升血压最快| 高考什么时候恢复| 四个火念什么字| 马兰头是什么菜| 陕西为什么叫三秦大地| 信口雌黄是什么意思| 鲑鱼是什么鱼| 豆角没熟中毒什么症状| 覆水难收什么意思| 海蜇是什么动物| 荆条是什么意思| 鱼肝油什么时候吃最好| 甲功七项挂什么科| 身上长扁平疣是什么原因造成的| 红领巾的含义是什么| 肾气不固吃什么中成药| 肉桂粉是什么做的| 禾加一笔是什么字| 有什么水果| jk制服是什么意思| 水肿是什么原因| 血肿是什么意思| 健康证有什么用| 25分贝相当于什么声音| 贫血是什么原因引起的| 什么是前奶什么是后奶| 3.21什么星座| 过敏性鼻炎吃什么药能快速缓解| 什么是省控线| 嘴巴里苦是什么原因| 厉兵秣马是什么意思| 溥仪和慈禧什么关系| 紫苏叶有什么作用| 橱柜用什么材料好| 山药和什么不能一起吃| 小孩子上火吃什么能降火| 噗是什么意思| 履约是什么意思| 银耳和什么一起煮最好| 孩子胆子小用什么方法可以改变| 软骨炎是什么病| 月季什么时候扦插最好| 真菌性龟头炎用什么药| 老虎下山下一句是什么| 女性脱发严重是什么原因引起的| 排便困难用什么药| 胆固醇高吃什么药| 一个王一个番读什么| 熊喜欢吃什么食物| 风湿病吃什么药| 什么是情劫| 菠菜什么季节吃| 伤风感冒吃什么药| 来源是什么意思| 7月12是什么星座| 小孩铅过高有什么症状| 好饭不怕晚什么意思| 原位杂交技术检查什么| 401什么意思| 右眼皮跳是什么原因| 总钙是什么意思| 十一月四日是什么星座| 宣发是什么意思| 贴士是什么意思| 什么食物含维生素k最多| 一点小事就暴躁的人是什么病| 4月29号0点是什么时候| 什么山没有石头| 聪明反被聪明误是什么意思| 可颂是什么意思| 妇乐颗粒的功效能治什么病| 禁欲是什么意思| 替身是什么意思| 七月八号是什么星座| 什么是奶昔| 素饺子什么馅儿的好吃| 脚心抽筋是什么原因引起的| 吃什么油对心脑血管好| 什么的北京城| 白萝卜煮水喝有什么功效| 什么是胎记| 周传雄得了什么病| 颈椎痛挂什么科| 骞字五行属什么| 6代表什么意思| 11月7号是什么星座| 舌苔白厚有齿痕是什么原因| 身上痒但是什么都没有| 上火嗓子疼吃什么药| 肾上腺是什么意思| 脾的作用是什么| 蜂胶是什么| 慢悠悠的近义词是什么| 乳腺b超挂什么科| 亦什么意思| 河蚌吃什么食物| 甲氨蝶呤是什么药| 上炕是什么意思| 机车什么意思| 低蛋白血症吃什么最快| 孕囊是什么东西| 心什么肉什么| 血小板压积偏低是什么原因| 做梦梦见火是什么意思| 晚上经常做梦是什么原因| 树大招风的意思是什么| 能量棒是什么东西| 什么叫免疫力| 矫正视力是指什么| 渴望是什么意思| 中暑不能吃什么| 什么是良心| 双子座是什么象星座| 炖牛肉放什么料| 软蛋是什么意思| 染色体是什么| 关联词是什么意思| 微量元素检查挂什么科| 薏米和什么一起煮粥最好| 海带和什么相克| 孕妇梦见好多蛇是什么预兆| 老年阴道炎用什么药| 肌酐高什么东西不能吃| 手脚发麻吃什么药| 哈库呐玛塔塔什么意思| 纱布是什么材质| 黄痰吃什么药| 为什么会得肠梗阻| 八月生日什么星座| 慢性非萎缩性胃炎伴糜烂是什么意思| 尿酸520属于什么水平| 胳肢窝疼痛是什么原因| 心理卫生科看什么病的| 李子什么时候成熟| 追什么| 月经流的是什么血| 世界上最贵的车是什么车| 指腹为婚是什么意思| 02年是什么命| 杂合突变型是什么意思| 69是什么| 沙弗莱是什么宝石| 天兵神将是什么动物| 86年属什么| 尿素是什么意思| 心肾不交有什么症状| 小孩吃榴莲有什么好处| 打呼噜吃什么| 戒奶涨奶痛有什么缓解方法| 危楼是什么意思| 狗狗拉虫子又细又长吃什么药| 氟比洛芬是什么药| 宿便是什么颜色| 什么病不能吃西兰花| 未央是什么意思| 心率偏高是什么原因| 琋字五行属什么| 蚂蚁喜欢什么环境| 皮肤发黄是什么原因| 猫砂是干什么用的| 日本的国宝是什么| 带状疱疹后遗神经痛挂什么科| 不规则抗体筛查是什么意思| 什么原因引起尿酸高| 筋膜炎是什么| 割包为什么很多人后悔| 虾为什么叫对虾| 沙中土命什么意思| 女生腋毛多是什么原因| 琀是什么意思| 小孩经常肚子疼是什么原因| 什么药止血效果最快| cy是什么意思| 双相是什么| 十万为什么| 入港是什么意思| cathy什么意思| lpp什么意思| 什么药能治阳痿早泄| 舌头发白什么原因| 龟皮痒用什么药膏| 砚是什么意思| 为什么会莫名其妙流鼻血| 低密度脂蛋白高有什么危害| 反应蛋白高是什么意思| 右脚浮肿预示着什么| 分娩是什么意思| 减肥什么时候喝牛奶| 颈部疼痛挂什么科| 舌头两边锯齿状是什么原因| 足下生辉是什么意思| 足三里在什么位置| 有趣是什么意思| 什么叫慢阻肺| 低脂牛奶适合什么人喝| 肠痈是什么病| kkp什么意思| 备孕叶酸什么时候吃最好| 兔子的天敌是什么动物| 天牛吃什么| pab是什么意思| 词牌名什么意思| 备孕吃叶酸有什么好处| 尿蛋白弱阳性什么意思| 跳蚤是什么样的图片| 西替利嗪是什么药| squirrel是什么意思| chilli是什么意思| 低钠盐是什么意思| 黄疸高是什么原因引起的| 白细胞低是什么原因造成的| s1隐裂是什么意思| 射手是什么星座| 亚硝酸钠是什么| 慢性肾炎是什么原因引起的| 男孩什么时辰出生最好| 百度Jump to content

左眼皮老是跳是什么原因

From Wikipedia, the free encyclopedia
百度 朗逸常规后备厢容积为478L,内部也非常平整,第二排座椅可按4/6比例放倒,获得更加充裕的装载空间。

In computing, type introspection is the ability of a program to examine the type or properties of an object at runtime. Some programming languages possess this capability.

Introspection should not be confused with reflection, which goes a step further and is the ability for a program to manipulate the metadata, properties, and functions of an object at runtime. Some programming languages also possess that capability (e.g., Java, Python, Julia, and Go).

Examples

[edit]

C++

[edit]

C++ supports type introspection via the run-time type information (RTTI) typeid and dynamic cast keywords. The dynamic_cast expression can be used to determine whether a particular object is of a particular derived class. For instance:

Person* p = dynamic_cast<Person *>(obj);
if (p != nullptr) {
  p->walk();
}

The typeid operator retrieves a std::type_info object describing the most derived type of an object:

if (typeid(Person) == typeid(*obj)) {
  serialize_person( obj );
}

C#

[edit]

In C# introspection can be done using the is keyword. For instance:

if (obj is Person)
{
    // Do whatever you want
}

Objective-C

[edit]

In Objective-C, for example, both the generic Object and NSObject (in Cocoa/OpenStep) provide the method isMemberOfClass: which returns true if the argument to the method is an instance of the specified class. The method isKindOfClass: analogously returns true if the argument inherits from the specified class.

For example, say we have an Apple and an Orange class inheriting from Fruit.

Now, in the eat method we can write

- (void)eat:(id)sth {
    if ([sth isKindOfClass:[Fruit class]]) {
        // we're actually eating a Fruit, so continue
        if ([sth isMemberOfClass:[Apple class]]) {
            eatApple(sth);
        } else if ([sth isMemberOfClass:[Orange class]]) {
            eatOrange(sth);
        } else {
            error();
        }
    } else {
        error();
    }
}

Now, when eat is called with a generic object (an id), the function will behave correctly depending on the type of the generic object.

Object Pascal

[edit]

Type introspection has been a part of Object Pascal since the original release of Delphi, which uses RTTI heavily for visual form design. In Object Pascal, all classes descend from the base TObject class, which implements basic RTTI functionality. Every class's name can be referenced in code for RTTI purposes; the class name identifier is implemented as a pointer to the class's metadata, which can be declared and used as a variable of type TClass. The language includes an is operator, to determine if an object is or descends from a given class, an as operator, providing a type-checked typecast, and several TObject methods. Deeper introspection (enumerating fields and methods) is traditionally only supported for objects declared in the $M+ (a pragma) state, typically TPersistent, and only for symbols defined in the published section. Delphi 2010 increased this to nearly all symbols.

procedure Form1.MyButtonOnClick(Sender: TObject);
var
   aButton: TButton;
   SenderClass: TClass;
begin
   SenderClass := Sender.ClassType; //returns Sender's class pointer
   if sender is TButton then
   begin
      aButton := sender as TButton;
      EditBox.Text := aButton.Caption; //Property that the button has but generic objects don't
   end
   else begin
      EditBox.Text := Sender.ClassName; //returns the name of Sender's class as a string
   end;
end;

Java

[edit]

The simplest example of type introspection in Java is the instanceof[1] operator. The instanceof operator determines whether a particular object belongs to a particular class (or a subclass of that class, or a class that implements that interface). For instance:

if (obj instanceof Person p) {
    p.walk();
}

The java.lang.Class[2] class is the basis of more advanced introspection.

For instance, if it is desirable to determine the actual class of an object (rather than whether it is a member of a particular class), Object.getClass() and Class.getName() can be used:

System.out.println(obj.getClass().getName());

PHP

[edit]

In PHP introspection can be done using instanceof operator. For instance:

if ($obj instanceof Person) {
    // Do whatever you want
}

Perl

[edit]

Introspection can be achieved using the ref and isa functions in Perl.

We can introspect the following classes and their corresponding instances:

package Animal;
sub new {
    my $class = shift;
    return bless {}, $class;
}

package Dog;
use base 'Animal';

package main;
my $animal = Animal->new();
my $dog = Dog->new();

using:

print "This is an Animal.\n" if ref $animal eq 'Animal';
print "Dog is an Animal.\n" if $dog->isa('Animal');

Meta-Object Protocol

[edit]

Much more powerful introspection in Perl can be achieved using the Moose object system[3] and the Class::MOP meta-object protocol;[4] for example, you can check if a given object does a role X:

if ($object->meta->does_role("X")) {
    # do something ...
}

This is how you can list fully qualified names of all of the methods that can be invoked on the object, together with the classes in which they were defined:

for my $method ($object->meta->get_all_methods) {
    print $method->fully_qualified_name, "\n";
}

Python

[edit]

The most common method of introspection in Python is using the dir function to detail the attributes of an object. For example:

class Foo:
    def __init__(self, val):
        self.x = val

    def bar(self):
        return self.x
>>> dir(Foo(5))
['__class__', '__delattr__', '__dict__', '__doc__', '__getattribute__',
'__hash__', '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__',
'__repr__', '__setattr__', '__str__', '__weakref__', 'bar', 'x']

Also, the built-in functions type and isinstance can be used to determine what an object is while hasattr can determine what an object does. For example:

>>> a = Foo(10)
>>> b = Bar(11)
>>> type(a)
<type 'Foo'>
>>> isinstance(a, Foo)
True
>>> isinstance(a, type(a))
True
>>> isinstance(a, type(b))
False
>>> hasattr(a, 'bar')
True

Ruby

[edit]

Type introspection is a core feature of Ruby. In Ruby, the Object class (ancestor of every class) provides Object#instance_of? and Object#kind_of? methods for checking the instance's class. The latter returns true when the particular instance the message was sent to is an instance of a descendant of the class in question. For example, consider the following example code (you can immediately try this with the Interactive Ruby Shell):

$ irb
irb(main):001:0> A=Class.new
=> A
irb(main):002:0> B=Class.new A
=> B
irb(main):003:0> a=A.new
=> #<A:0x2e44b78>
irb(main):004:0> b=B.new
=> #<B:0x2e431b0>
irb(main):005:0> a.instance_of? A
=> true
irb(main):006:0> b.instance_of? A
=> false
irb(main):007:0> b.kind_of? A
=> true

In the example above, the Class class is used as any other class in Ruby. Two classes are created, A and B, the former is being a superclass of the latter, then one instance of each class is checked. The last expression gives true because A is a superclass of the class of b.

Further, you can directly ask for the class of any object, and "compare" them (code below assumes having executed the code above):

irb(main):008:0> A.instance_of? Class
=> true
irb(main):009:0> a.class
=> A
irb(main):010:0> a.class.class
=> Class
irb(main):011:0> A > B
=> true
irb(main):012:0> B <= A
=> true

ActionScript

[edit]

In ActionScript (as3), the function flash.utils.getQualifiedClassName can be used to retrieve the class/type name of an arbitrary object.

// all classes used in as3 must be imported explicitly
import flash.utils.getQualifiedClassName;
import flash.display.Sprite;
// trace is like System.out.println in Java or echo in PHP
trace(flash.utils.getQualifiedClassName("I'm a String")); // "String"
trace(flash.utils.getQualifiedClassName(1)); // "int", see dynamic casting for why not Number
trace(flash.utils.getQualifiedClassName(new flash.display.Sprite())); // "flash.display.Sprite"

Alternatively, the operator is can be used to determine if an object is of a specific type:

// trace is like System.out.println in Java or echo in PHP
trace("I'm a String" is String); // true
trace(1 is String); // false
trace("I'm a String" is Number); // false
trace(1 is Number); // true

This second function can be used to test class inheritance parents as well:

import flash.display.DisplayObject;
import flash.display.Sprite; // extends DisplayObject

trace(new flash.display.Sprite() is flash.display.Sprite); // true
trace(new flash.display.Sprite() is flash.display.DisplayObject); // true, because Sprite extends DisplayObject
trace(new flash.display.Sprite() is String); // false

Meta-type introspection

[edit]

Like Perl, ActionScript can go further than getting the class name, but all the metadata, functions and other elements that make up an object using the flash.utils.describeType function; this is used when implementing reflection in ActionScript.

import flash.utils.describeType;
import flash.utils.getDefinitionByName;
import flash.utils.getQualifiedClassName;
import flash.display.Sprite;

var className:String = getQualifiedClassName(new flash.display.Sprite()); // "flash.display.Sprite"
var classRef:Class = getDefinitionByName(className); // Class reference to flash.display{{Not a typo|.}}Sprite
// eg. 'new classRef()' same as 'new  flash.display.Sprite()'
trace(describeType(classRef)); // return XML object describing type
// same as : trace(describeType(flash.display.Sprite));

See also

[edit]

References

[edit]
[edit]
gravy是什么意思 扛把子是什么意思 排山倒海是什么意思 减肥吃什么油 眉州东坡是什么菜系
风热感冒吃什么药最好 女人脚浮肿是什么原因 一直流口水是什么原因 舌头发麻什么原因 于是什么意思
经常挖鼻孔有什么危害 大林木是什么生肖 嘴巴周围长痘痘是什么原因 电信诈骗是什么意思 什么是凯格尔运动
山楂泡酒有什么功效 老年斑是什么原因引起的 盆腔积液是什么 11月11号什么星座 传导阻滞吃什么药
一个提手一个京念什么hcv9jop7ns2r.cn 1943年属什么生肖helloaicloud.com 分期是什么意思hcv9jop0ns8r.cn 家家酒是什么意思hcv8jop8ns1r.cn head是什么牌子hcv7jop6ns6r.cn
elephant什么意思hcv8jop5ns0r.cn resp是什么hcv8jop2ns5r.cn 农历10月22日是什么星座hcv8jop3ns0r.cn 土鸡炖什么好吃hcv9jop1ns2r.cn 属狗的是什么命hcv8jop1ns2r.cn
前列腺穿刺是什么意思hcv8jop5ns1r.cn 胃火喝什么茶降火hcv7jop9ns5r.cn 小学什么时候报名hcv7jop5ns5r.cn 甲氧氯普胺片又叫什么hcv8jop0ns9r.cn 咳嗽黄痰是什么原因hcv9jop5ns8r.cn
关二爷是什么神hcv7jop6ns4r.cn 土地出让是什么意思beikeqingting.com 衣字旁的字和什么有关hcv8jop2ns4r.cn 打喷嚏鼻塞吃什么药hcv8jop3ns4r.cn 512是什么星座hcv8jop5ns5r.cn
百度