mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* struct.c (Struct.new): Document Struct.new with block
Patch by Hiroyuki Iwatsuki [Bug #7674] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38883 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
b7ae472b58
commit
eed593eba6
2 changed files with 19 additions and 3 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Sat Jan 19 11:35:00 2013 Zachary Scott <zachary@zacharyscott.net>
|
||||||
|
|
||||||
|
* struct.c (Struct.new): Document Struct.new with block
|
||||||
|
Patch by Hiroyuki Iwatsuki [Bug #7674]
|
||||||
|
|
||||||
Sat Jan 19 09:52:46 2013 Eric Hodel <drbrain@segment7.net>
|
Sat Jan 19 09:52:46 2013 Eric Hodel <drbrain@segment7.net>
|
||||||
|
|
||||||
* doc/syntax/miscellaneous.rdoc: Added section on defined?
|
* doc/syntax/miscellaneous.rdoc: Added section on defined?
|
||||||
|
|
17
struct.c
17
struct.c
|
@ -283,9 +283,10 @@ rb_struct_define(const char *name, ...)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* Struct.new( [aString] [, aSym]+> ) -> StructClass
|
* Struct.new( [aString] [, aSym]+> ) -> StructClass
|
||||||
* StructClass.new(arg, ...) -> obj
|
* Struct.new( [aString] [, aSym]+> ) {|StructClass| block } -> StructClass
|
||||||
* StructClass[arg, ...] -> obj
|
* StructClass.new(arg, ...) -> obj
|
||||||
|
* StructClass[arg, ...] -> obj
|
||||||
*
|
*
|
||||||
* Creates a new class, named by <i>aString</i>, containing accessor
|
* Creates a new class, named by <i>aString</i>, containing accessor
|
||||||
* methods for the given symbols. If the name <i>aString</i> is
|
* methods for the given symbols. If the name <i>aString</i> is
|
||||||
|
@ -296,6 +297,16 @@ rb_struct_define(const char *name, ...)
|
||||||
* letter. Assigning a structure class to a constant effectively gives
|
* letter. Assigning a structure class to a constant effectively gives
|
||||||
* the class the name of the constant.
|
* the class the name of the constant.
|
||||||
*
|
*
|
||||||
|
* If a block is given, it will be evaluated in the context of
|
||||||
|
* <i>StructClass</i>, passing <i>StructClass</i> as a parameter.
|
||||||
|
*
|
||||||
|
* Customer = Struct.new(:name, :address) do
|
||||||
|
* def greeting
|
||||||
|
* "Hello #{name}!"
|
||||||
|
* end
|
||||||
|
* end
|
||||||
|
* Customer.new("Dave", "123 Main").greeting # => "Hello Dave!"
|
||||||
|
*
|
||||||
* <code>Struct::new</code> returns a new <code>Class</code> object,
|
* <code>Struct::new</code> returns a new <code>Class</code> object,
|
||||||
* which can then be used to create specific instances of the new
|
* which can then be used to create specific instances of the new
|
||||||
* structure. The number of actual parameters must be
|
* structure. The number of actual parameters must be
|
||||||
|
|
Loading…
Reference in a new issue