Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS 

Ruby - "meta method" execute

//
//
// attempt to execute a method indirectly, I don't know if
// it's possible, but I suspect it is, and probably just
// have the syntax wrong
//

ar = %w(apples bananas oranges)

print "\n ar.class = #{ar.class}"

print "\n ar.methods = #{ar.methods.sort}"
puts "======================================================="

mets = ar.methods.sort

#
# this doesn't work ... is there a syntax for doing this?
#                       i.e. calling a 'meta' method ?
#
# call each method of 'ar' (an array)
#
#

mets.each {|method| ar.method} 

« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS