зеркало из https://github.com/github/ruby.git
Small changes to documentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3392 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
b95357be1a
Коммит
d67106c081
18
lib/set.rb
18
lib/set.rb
|
@ -48,7 +48,7 @@ class Set
|
|||
#
|
||||
# If a block is given, the elements of enum are preprocessed by the
|
||||
# given block.
|
||||
def initialize(enum = nil, &block)
|
||||
def initialize(enum = nil, &block) # :yields: o
|
||||
@hash ||= Hash.new
|
||||
|
||||
enum.nil? and return
|
||||
|
@ -322,10 +322,10 @@ class Set
|
|||
# require 'set'
|
||||
# files = Set.new(Dir.glob("*.rb"))
|
||||
# hash = files.classify { |f| File.mtime(f).year }
|
||||
# p hash #=> {2000=>#<Set: {"a.rb", "b.rb"}>,
|
||||
# # 2001=>#<Set: {"c.rb", "d.rb", "e.rb"}>,
|
||||
# # 2002=>#<Set: {"f.rb"}>}
|
||||
def classify
|
||||
# p hash # => {2000=>#<Set: {"a.rb", "b.rb"}>,
|
||||
# # 2001=>#<Set: {"c.rb", "d.rb", "e.rb"}>,
|
||||
# # 2002=>#<Set: {"f.rb"}>}
|
||||
def classify # :yields: o
|
||||
h = {}
|
||||
|
||||
each { |i|
|
||||
|
@ -348,10 +348,10 @@ class Set
|
|||
# require 'set'
|
||||
# numbers = Set[1, 3, 4, 6, 9, 10, 11]
|
||||
# set = numbers.divide { |i,j| (i - j).abs == 1 }
|
||||
# p set #=> #<Set: {#<Set: {1}>,
|
||||
# # #<Set: {11, 9, 10}>,
|
||||
# # #<Set: {3, 4}>,
|
||||
# # #<Set: {6}>}>
|
||||
# p set # => #<Set: {#<Set: {1}>,
|
||||
# # #<Set: {11, 9, 10}>,
|
||||
# # #<Set: {3, 4}>,
|
||||
# # #<Set: {6}>}>
|
||||
def divide(&func)
|
||||
if func.arity == 2
|
||||
require 'tsort'
|
||||
|
|
Загрузка…
Ссылка в новой задаче