Search
 
SCRIPT & CODE EXAMPLE
 

RUBY

ruby array of symbols shorthand

2.4.2 :001 > a = 1
2.4.2 :002 > %i{one two #{a}+three} # Interpolation is ignored
 => [:one, :two, :"#{a}+three"]
2.4.2 :003 > %I{one two #{a}+three} # Interpolation works
 => [:one, :two, :"1+three"]
Comment

ruby array of symbols

# Array of symbols
%i[address city state post_code country]
=> [:address, :city, :state, :post_code, :country]

# Array of strings
 %w[address city state postal country]
=> ["address", "city", "state", "postal", "country"]

# Array of interpolated symbols
postal_label = 'zip'
%I[address city state #{postal_label} country]
=> [:address, :city, :state, :zip, :country]

# Array of interpolated strings
%W[address city state #{postal_label} country]
=> ["address", "city", "state", "zip", "country"]
# Instead of %i[] you may use %i{} or %i() or %i!!
Comment

PREVIOUS NEXT
Code Example
Ruby :: ruby clear set 
Ruby :: expect actionmailer base nullmail 
Ruby :: simple form change id 
Ruby :: find subset of two hashes in ruby 
Ruby :: my rails server exits automatically and now gives the following error: 
Ruby :: run bundle without production in rails 
Ruby :: ruby 3 one line method 
Ruby :: ruby find by multiple columns 
Ruby :: how do i fix FATAL: password authentication failed for user "root" 
Ruby :: devise trackable not working for authentication 
Ruby :: rails convert euro to dollar 
Ruby :: update_all 
Ruby :: rails update column without callbacks 
Ruby :: logstash-logger gem 
Ruby :: compiler version at runtime 
Ruby :: ruby read file line by line 
R :: r delete all variables 
R :: generate all possible combinations of a set of characters r 
R :: defulat function values R 
R :: sort R 
R :: r create a list 
R :: combine columns in r 
R :: how to read in a text file in r 
R :: remove first and last character from string R 
R :: what is a vector in r 
R :: attr(* label )= chr in r 
R :: r select rows 
R :: ggplot glm 
R :: count certain number of alphabets in a string r 
R :: two letter country code in r 
ADD CONTENT
Topic
Content
Source link
Name
2+6 =