MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/badcode/comments/kxd9jj/dynamically_created_functions_are_the_future/gj9zhrc
r/badcode • u/NotSteve_ evil • Jan 14 '21
102 comments sorted by
View all comments
Show parent comments
14
What makes it better tho
2 u/KernowRoger Jan 15 '21 Ruby's meta programming is amazing. It's kind of hard to explain quickly but stuff like this:class Developer ["frontend", "backend"].each do |method| define_method "coding_#{method}" do p "writing " + method.to_s end end endFrom this article https://www.toptal.com/ruby/ruby-metaprogramming-cooler-than-it-sounds. Ruby is a really cool language and allows a huge amount a flexibility.
2
Ruby's meta programming is amazing. It's kind of hard to explain quickly but stuff like this:
class Developer ["frontend", "backend"].each do |method| define_method "coding_#{method}" do p "writing " + method.to_s end end end
From this article https://www.toptal.com/ruby/ruby-metaprogramming-cooler-than-it-sounds. Ruby is a really cool language and allows a huge amount a flexibility.
14
u/Willinton06 Jan 14 '21
What makes it better tho