Permalink
Browse files

Updated AS guide with new Object#in? and Object#either? methods

  • Loading branch information...
1 parent 3f283c2 commit 7a1189a2c75b16f86a11c1d2379c50b11a7a2d66 @smartinez87 smartinez87 committed Apr 11, 2011
Showing with 22 additions and 0 deletions.
  1. +22 −0 railties/guides/source/active_support_core_extensions.textile
@@ -442,6 +442,28 @@ require_library_or_gem('mysql')
NOTE: Defined in +active_support/core_ext/kernel/requires.rb+.
+h4. +in?+ and +either?+
+
+The predicate +in?+ tests if an object is included in another object, and the predicate +either?+ tests if an object is included in a list of objects which will be passed as arguments.
+
+Examples of +in?+:
+
+<ruby>
+ 1.in?([1,2]) # => true
+ "lo".in?("hello") # => true
+ 25.in?(30..50) # => false
+</ruby>
+
+Examples of +either?+:
+
+<ruby>
+ 1.either?(1,2,3) # => true
+ 5.either?(1,2,3) # => false
+ [1,2,3].either?([1,2,3], 2, [3,4,5]) # => true
+</ruby>
+
+NOTE: Defined in +active_support/core_ext/object/inclusion.rb+.
+
h3. Extensions to +Module+
h4. +alias_method_chain+

3 comments on commit 7a1189a

Member

sikachu replied Apr 13, 2011

Thank you :)

BTW, it's now Object#among? and seems like it will be removed too.

Contributor

gnufied replied Apr 13, 2011

Either is horrible name for what it does. Whats the use case anyways?

Contributor

gnufied replied Apr 13, 2011

Okay, I see that the name has been changed, so that makes me happy.

Please sign in to comment.