Search
 
SCRIPT & CODE EXAMPLE
 

RUBY

ruby name parameters

def foo(bar: 'default')
  puts bar
end

foo # => 'default'
foo(bar: 'baz') # => 'baz'
Comment

ruby named parameters

def show_name_and_address(name: "Someone", address: "Somewhere")
  puts "#{name}, #{address}"
end

show_name_and_address
#=> 'Someone, Somewhere'

show_name_and_address(name: 'Andy')
#=> 'Andy, Somewhere'

show_name_and_address(address: 'USA')
#=> 'Someone, USA'
Comment

ruby named parameters

def show_name_and_address(name="Someone", address="Somewhere")
  puts "#{name}, #{address}"
end

show_name_and_address
#=> 'Someone, Somewhere'

show_name_and_address('Andy')
#=> 'Andy, Somewhere'
Comment

PREVIOUS NEXT
Code Example
Ruby :: how do I update an index in rails 
Ruby :: ruby string format 
Ruby :: ide for ruby 
Ruby :: ruby on rails examples 
Ruby :: user.destroy all except one rails 
Ruby :: add elements to ruby hashes 
Ruby :: ||= ruby 
Ruby :: * 16**index position in ruby 
Ruby :: EOFError: end of file reached 
Ruby :: Hash.new constructor 
Ruby :: rails interrupt if tooo long 
Ruby :: is identation madatory in ruby 
Ruby :: my rails server exits automatically 
Ruby :: ruby rails update email skip confirm email 
Ruby :: how to overwrite last line of console in ubuntu rails 
Ruby :: apple calendar gem in rails 
Ruby :: Many to Many Active Record 
Ruby :: ruby check if string is integer 
R :: r sort character number 
R :: r remove rows where value is 0 
R :: line split r 
R :: r rename columns 
R :: comments in r 
R :: columns of a datafram in r 
R :: r replace na with 0 
R :: r number of blanks in the data 
R :: Derive end of the week date in r 
R :: if a condition is true skip loop r 
R :: insert a png in R 
R :: no redundant combination expand grid 
ADD CONTENT
Topic
Content
Source link
Name
2+9 =