For example:
ABC = 'abc'
DEF = 'def'
XYZ = 'anything'
LIST_ALL = [ABC, DEF, XYZ]
If I do
LIST_ALL.reject(&:blank?).join(', ') # => "abc, def, anything"
What I am looking for is to get the constant names, not their values Expected output:
LIST_ALL.something() #=> "ABC, DEF, XYZ"
Approach #1:
class X
ABC = "abc"
DEF = "def"
GHI = ""
XYZ = "anything"
LIST_ALL = %w(ABC DEF GHI XYZ)
def self.something()
puts LIST_ALL.reject{|c| c.constantize.blank?}.join(', ')
# puts LIST_ALL[0].constantize
end
end
Error:
(NameError) uninitialized constant ABC;