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
I like the idea of safe autogenerated getters. But every time I have to check the length of an array I am confused as this job is so routine and dumb that is a perfect match for a autogenerated wrapper.
Consider example
if len(val.GetArrayField()) > 0 {
val.GetArrayfield()[0].GetSomeNestedField()
}
can become
val.GetArrayfieldItem(0).GetSomeNestedField()
All we need is to generate array getter like this:
func (Value *v) GetArrayfieldItem(int32 index) *Field
if v != nil && index >= 0 && len(val.ArrayField) > index {
return val.ArrayField[index]
}
return nil
Is there any fundamental reasons why we cannot have array getters like this or nobody just got to do it?
The text was updated successfully, but these errors were encountered:
kanstantsin-chernik
changed the title
Is there a reason why we cannot have a getter for an array items?
Is there a reason why we cannot have a getter for array items?
Nov 24, 2021
@89z this is just one use case which is already supported. I have use cases when I need a very specific item and accessing it with nested structure becoming ugly. Also, this feature can be configurable.
I like the idea of safe autogenerated getters. But every time I have to check the length of an array I am confused as this job is so routine and dumb that is a perfect match for a autogenerated wrapper.
Consider example
can become
All we need is to generate array getter like this:
Is there any fundamental reasons why we cannot have array getters like this or nobody just got to do it?
The text was updated successfully, but these errors were encountered: