V
Vicente Bosch Campos
Hi,
I am doing an implementation of a genetic algorithm to resolve a certain =
type of equations. I need to randomly call a certain method from a set:
def mutation
=20
self.send(self.methods.select!{|element| =
element.to_s.end_with?("Mutation")}.shuffle![0]) #I'm using to_s as =
the symbol object do not allow end_with?
=20
end
=20
def operatorSwitchMutation
end
=20
def numberSwitchMutation
end
=20
def unusedNumberMutation
end
Is self.send(self.methods.select!{|element| =
element.to_s.end_with?("Mutation")}.shuffle![0]) the best way to do it ? =
Is there a more ruby idiom to perform the safe thing ?
Best,
V.=20=
I am doing an implementation of a genetic algorithm to resolve a certain =
type of equations. I need to randomly call a certain method from a set:
def mutation
=20
self.send(self.methods.select!{|element| =
element.to_s.end_with?("Mutation")}.shuffle![0]) #I'm using to_s as =
the symbol object do not allow end_with?
=20
end
=20
def operatorSwitchMutation
end
=20
def numberSwitchMutation
end
=20
def unusedNumberMutation
end
Is self.send(self.methods.select!{|element| =
element.to_s.end_with?("Mutation")}.shuffle![0]) the best way to do it ? =
Is there a more ruby idiom to perform the safe thing ?
Best,
V.=20=