Search
 
SCRIPT & CODE EXAMPLE
 

RUBY

ruby raise argumenterror

# raise ArgumentError, 'Put error message here' unless some_condition
# example from source link

def inverse(x)  
  raise ArgumentError, 'Argument is not numeric' unless x.is_a? Numeric  
  1.0 / x  
end  

puts inverse(2) # 0.5
puts inverse('not a number') # ArgumentError
Comment

PREVIOUS NEXT
Code Example
Ruby :: rails crud 
Ruby :: how to delete database in rails 
Ruby :: rails form_tag 
Ruby :: ruby get decimal 
Ruby :: liquid add date 
Ruby :: new date ruby 
Ruby :: if rails.env.development 
Ruby :: how to create 2 dimensional array in ruby 
Ruby :: ruby array unshift 
Ruby :: create a new hash from existing hash ruby 
Ruby :: how add an index column in rails 
Ruby :: read xls file in ruby 
Ruby :: ruby rails where not in 
Ruby :: rails keep all params except for some 
Ruby :: ruby rails find data field type 
Ruby :: arel_table rails 
Ruby :: DEPRECATION WARNING: Sprockets method `register_engine` is deprecated. 
Ruby :: ruby join hash to string 
Ruby :: how to display the has_many in the api serializer rails 
Ruby :: ruby get min value from array 
Ruby :: rails edit models 
Ruby :: ruby rspec change matcher 
Ruby :: ruby 3 one line method 
Ruby :: rails order nil last 
Ruby :: rails db:drop not working 
Ruby :: ruby on rails db column contains string 
Ruby :: does destroy retrurn in ruby 
R :: r find elements in common between vectors 
R :: r import table with readr 
R :: r dataframe column factor 
ADD CONTENT
Topic
Content
Source link
Name
1+3 =