Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to do meta programming in Swift

Is there a way to dynamically generate methods in a class like in Ruby in Swift? Can this be done by setting instance variables to be a function like in Javascript.

like image 475
user3735062 Avatar asked Jun 14 '14 02:06

user3735062


1 Answers

The book The Swift Programming Language doesn't mention anything.

As that is the definitive guide to the language we have right now, this seems like bad luck. As swift is based on the ObjC language runtime however, which has metaprogramming abilities, there ought to be some way to do it.

So lets wait and see.

like image 183
user132837 Avatar answered Nov 15 '22 10:11

user132837