mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	[DOC] Integer.try_convert [ci skip]
This commit is contained in:
		
							parent
							
								
									af6e088357
								
							
						
					
					
						commit
						454b4da763
					
				
					 2 changed files with 20 additions and 0 deletions
				
			
		| 
						 | 
				
			
			@ -5991,6 +5991,7 @@ rb_int_s_isqrt(VALUE self, VALUE num)
 | 
			
		|||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* :nodoc: */
 | 
			
		||||
static VALUE
 | 
			
		||||
int_s_try_convert(VALUE self, VALUE num)
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										19
									
								
								numeric.rb
									
										
									
									
									
								
							
							
						
						
									
										19
									
								
								numeric.rb
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -229,6 +229,25 @@ class Integer
 | 
			
		|||
  end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
#  call-seq:
 | 
			
		||||
#    Integer.try_convert(object) -> object, integer, or nil
 | 
			
		||||
#
 | 
			
		||||
#  If +object+ is an \Integer object, returns +object+.
 | 
			
		||||
#
 | 
			
		||||
#  Otherwise if +object+ responds to <tt>:to_int</tt>,
 | 
			
		||||
#  calls <tt>object.to_int</tt> and returns the result.
 | 
			
		||||
#
 | 
			
		||||
#  Returns +nil+ if +object+ does not respond to <tt>:to_ary</tt>
 | 
			
		||||
#
 | 
			
		||||
#  Raises an exception unless <tt>object.to_int</tt> returns an \Integer object.
 | 
			
		||||
#
 | 
			
		||||
def Integer.try_convert(num)
 | 
			
		||||
=begin
 | 
			
		||||
  Primitive.attr! 'inline'
 | 
			
		||||
  Primitive.cexpr! 'rb_check_integer_type(num)'
 | 
			
		||||
=end
 | 
			
		||||
end if false
 | 
			
		||||
 | 
			
		||||
class Float
 | 
			
		||||
  #
 | 
			
		||||
  # call-seq:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue