[前][次][番号順一覧][スレッド一覧]

ruby-changes:32645

From: zzak <ko1@a...>
Date: Tue, 28 Jan 2014 15:19:26 +0900 (JST)
Subject: [ruby-changes:32645] zzak:r44724 (trunk): * lib/set.rb: [DOC] Add examples for Set#intersect? and Set#disjoint?

zzak	2014-01-28 15:19:19 +0900 (Tue, 28 Jan 2014)

  New Revision: 44724

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=44724

  Log:
    * lib/set.rb: [DOC] Add examples for Set#intersect? and Set#disjoint?
      Patch by xavier nayrac [Bug #9331] [ci skip]

  Modified files:
    trunk/ChangeLog
    trunk/lib/set.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 44723)
+++ ChangeLog	(revision 44724)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Tue Jan 28 15:17:59 2014  Zachary Scott  <e@z...>
+
+	* lib/set.rb: [DOC] Add examples for Set#intersect? and Set#disjoint?
+	  Patch by xavier nayrac [Bug #9331] [ci skip]
+
 Tue Jan 28 15:12:22 2014  Zachary Scott  <e@z...>
 
 	* ext/zlib/zlib.c (rb_zlib_adler32): [DOC] Add example for adler32
Index: lib/set.rb
===================================================================
--- lib/set.rb	(revision 44723)
+++ lib/set.rb	(revision 44724)
@@ -240,6 +240,12 @@ class Set https://github.com/ruby/ruby/blob/trunk/lib/set.rb#L240
 
   # Returns true if the set and the given set have at least one
   # element in common.
+  #
+  # e.g.:
+  #
+  #   require 'set'
+  #   Set[1, 2, 3].intersect? Set[4, 5] # => false
+  #   Set[1, 2, 3].intersect? Set[3, 4] # => true
   def intersect?(set)
     set.is_a?(Set) or raise ArgumentError, "value must be a set"
     if size < set.size
@@ -251,6 +257,13 @@ class Set https://github.com/ruby/ruby/blob/trunk/lib/set.rb#L257
 
   # Returns true if the set and the given set have no element in
   # common.  This method is the opposite of +intersect?+.
+  #
+  # e.g.:
+  #
+  #   require 'set'
+  #   Set[1, 2, 3].disjoint? Set[3, 4] # => false
+  #   Set[1, 2, 3].disjoint? Set[4, 5] # => true
+
   def disjoint?(set)
     !intersect?(set)
   end

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]