You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Consider the following class that extends VillageState to include a new variable, aggression.
customState <- R6Class("demographicState",
inherit = VillageState,
public = list(aggression,
initialize = function(aggression=NULL) {
# Let the base class initialize all of the other values
super$initialize()
self$aggression <- aggression
}
)
)
We can create a new state object with
initial_condition <- customState$new()
But. We can't do something like (I'm trying to set the variable in the base class)
VillageState is passé. The variables referenced above are slowly moving to other classes and are being managed with manager classes so this should no longer be an issue.
Consider the following class that extends
VillageState
to include a new variable,aggression
.We can create a new state object with
But. We can't do something like (I'm trying to set the variable in the base class)
Most languages have support for passing a variable number of arguments (for example pythons kwargs (actually exactly what I want to do)).
Goal: Use some sort of parameter pack/kwarg feature to pass values into the derived class's
initialize
method and feed them into the parent class.https://www.geeksforgeeks.org/packing-and-unpacking-arguments-in-python/
The text was updated successfully, but these errors were encountered: