File: ref_c_symbol.xml

package info (click to toggle)
rubybook 0.2-2
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 4,252 kB
  • ctags: 1,043
  • sloc: xml: 60,486; makefile: 25
file content (164 lines) | stat: -rw-r--r-- 3,807 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
<ppdoc>
<copyright>
    Copyright (c) 2001 by Addison Wesley Longman.  This
    material may be distributed only subject to the terms and
    conditions set forth in the Open Publication License, v1.0 or
    later (the latest version is presently available at
    http://www.opencontent.org/openpub/).
</copyright>
<class name="Symbol" super="Object" type="class">
<p/>
  A <classname>Symbol</classname> object represents a Ruby name and is generated
  automatically using the <tt>:name</tt> literal syntax. The same <classname>Symbol</classname>
  object will be created for a given name string for the duration of a
  program's execution, regardless of the context or meaning of that
  name. Thus if <tt>Fred</tt> is a constant in one context, a method in
  another, and a class in a third, the <classname>Symbol</classname> <tt>:Fred</tt> will be
  the same object in all three contexts.
<p/>
<codefragment>
<fullcode><![CDATA[    module One
      class Fred
      end
      $f1 = :Fred
    end
    module Two
      Fred = 1
      $f2 = :Fred
    end
    def Fred()
    end
    $f3 = :Fred
    $f1.id
    $f2.id
    $f3.id
]]></fullcode><rubycode>
<tr>
<td colspan="3"><tt>module<nbsp/>One</tt></td>
</tr>
<tr>
<td colspan="3"><tt><nbsp/><nbsp/>class<nbsp/>Fred</tt></td>
</tr>
<tr>
<td colspan="3"><tt><nbsp/><nbsp/>end</tt></td>
</tr>
<tr>
<td colspan="3"><tt><nbsp/><nbsp/>$f1<nbsp/>=<nbsp/>:Fred</tt></td>
</tr>
<tr>
<td colspan="3"><tt>end</tt></td>
</tr>
<tr>
<td colspan="3"><tt>module<nbsp/>Two</tt></td>
</tr>
<tr>
<td colspan="3"><tt><nbsp/><nbsp/>Fred<nbsp/>=<nbsp/>1</tt></td>
</tr>
<tr>
<td colspan="3"><tt><nbsp/><nbsp/>$f2<nbsp/>=<nbsp/>:Fred</tt></td>
</tr>
<tr>
<td colspan="3"><tt>end</tt></td>
</tr>
<tr>
<td colspan="3"><tt>def<nbsp/>Fred()</tt></td>
</tr>
<tr>
<td colspan="3"><tt>end</tt></td>
</tr>
<tr>
<td colspan="3"><tt>$f3<nbsp/>=<nbsp/>:Fred</tt></td>
</tr>
<tr>
  <td><tt>$f1.id</tt></td>
  <td>&#187;</td>
  <td><tt>2299150</tt></td>
</tr>
<tr>
  <td><tt>$f2.id</tt></td>
  <td>&#187;</td>
  <td><tt>2299150</tt></td>
</tr>
<tr>
  <td><tt>$f3.id</tt></td>
  <td>&#187;</td>
  <td><tt>2299150</tt></td>
</tr>
</rubycode>
<p/>
</codefragment>
<p/>
  <methods type="instance">
        <method name="id2name" ref="id2name">
      <callseq>
        <obj>sym</obj>.id2name <returns><obj>aString</obj></returns>
      </callseq>
      <desc>
<p/>
      Returns the name corresponding to <obj>sym</obj>.
<p/>
<codefragment>
<fullcode><![CDATA[        :fred.id2name
]]></fullcode><rubycode>
<tr>
  <td><tt>:fred.id2name</tt></td>
  <td>&#187;</td>
  <td><tt>"fred"</tt></td>
</tr>
</rubycode>
<p/>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="inspect" ref="inspect">
      <callseq>
        <obj>sym</obj>.inspect <returns><obj>aString</obj></returns>
      </callseq>
      <desc>
<p/>
      Returns the representation of <obj>sym</obj> as a symbol literal.
<p/>
<codefragment>
<fullcode><![CDATA[        :fred.inspect
]]></fullcode><rubycode>
<tr>
  <td><tt>:fred.inspect</tt></td>
  <td>&#187;</td>
  <td><tt>":fred"</tt></td>
</tr>
</rubycode>
<p/>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="to_i" ref="to_i">
      <callseq>
        <obj>sym</obj>.to_i  <returns><obj>aFixnum</obj></returns>
      </callseq>
      <desc>
<p/>
      Returns an integer that is unique for each symbol within a
      particular execution of a program.
<p/>
      </desc>
    </method>
<p/>
        <method name="to_s" ref="to_s">
      <callseq>
        <obj>sym</obj>.to_s <returns><obj>aString</obj></returns>
      </callseq>
      <desc>
<p/>
      Synonym for <cim><file>symbol</file><front>Symbol</front><back>id2name</back><mref>id2name</mref></cim>.
<p/>
      </desc>
    </method>
<p/>
  </methods>
<p/>
</class>
</ppdoc>