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 omit key 
Ruby :: will_paginate gem rails 
Ruby :: helper path outside view 
Ruby :: validations rails integer suprior to 0 
Ruby :: force user to login before action devise rails 
Ruby :: format date rails created long 
Ruby :: all rails g model types 
Ruby :: rails migration remove column 
Ruby :: ruby check if hash has method before calling it 
Ruby :: ruby on rails array contains multiple values 
Ruby :: rails link_to example 
Ruby :: ruby in array 
Ruby :: ruby sinatra helper 
Ruby :: important topic on ruby 
Ruby :: mobile money flutterwave payment 
Ruby :: rails model on validation custom column name 
Ruby :: # Create empty 2 dimensional array 
Ruby :: common functions in rails 
Ruby :: difference between is_a and kind_of ruby 
Ruby :: sequel not ruby 
Ruby :: rails decode cookie 
Ruby :: time_ago_in_words for created_at model in rails 
R :: ggplot increase label font size 
R :: tbale() in R 
R :: r box plots 
R :: chi square critical value in r 
R :: null count in r 
R :: R remove commas 
R :: quartile in r 
R :: how to tell if a variable is discrete or continuous in r 
ADD CONTENT
Topic
Content
Source link
Name
5+7 =