This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
arr = [4,1,2,7,"M","A","V"] | |
arr.partition { |a| a.is_a? String }.map(&:sort).flatten | |
p arr | |
=> | |
["A","V","M",1,2,4,7] | |
------- | |
a = [1, "A", nil, "M", "", ''] | |
a.reject!{|a| a.nil? || a.to_s.empty? } | |
p a | |
=> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=> name/value pairs | |
{ | |
"name":"value" | |
} | |
=> supports | |
number, strings, boolean, nil, array | |
=> | |
{ | |
"name":"value", | |
"array": [ 1,2,3 ], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1) Explain calling super and calling super() and give some example? | |
super and super() both inherits methods from parent class. super allows the arguments but super() dont allow the arguments. | |
Ex: | |
-- | |
class Niyati | |
def process(person,work) | |
"I am #{person} and am a #{work}" | |
end | |
end | |
OlderNewer