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
In practice, I often need to extract the same property of each item of an array, and generate a property array.
To get the name property of an item, we can simply call x.name. It should be equal to getproperty(x, :name).
Given the array A, currently I have to call getproperty.(A, :name) to generate the array of property name. (or, something like [x.name for x in A])
This function is very frequently used, and thus the code can be very verbose, comparing between x.name and getproperty.(A, :name).
I want a syntax like A..name to vectorize the process. I have tried the following method.
In practice, I often need to extract the same property of each item of an array, and generate a property array.
To get the
name
property of an item, we can simply callx.name
. It should be equal togetproperty(x, :name)
.Given the array
A
, currently I have to callgetproperty.(A, :name)
to generate the array of propertyname
. (or, something like[x.name for x in A]
)This function is very frequently used, and thus the code can be very verbose, comparing between
x.name
andgetproperty.(A, :name)
.I want a syntax like
A..name
to vectorize the process. I have tried the following method.which enables the following usage:
However,
A..a
would raiseUndefVarError
error.That is, the
:
can not be omitted unlikex.name
.May I ask if there is any possibility to solve it, or any other concise method to implement the feature?
Thank you very much!
The text was updated successfully, but these errors were encountered: