Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apache Thrift: Assign default values to enclosed struct

In an IDL file, I have

struct CaseInfo {
    1: CaseID = '',
    2: EvID = 'foobar',
}

struct Case {
    1: CaseInfo CaseInfo,
    2: string key = '',
}

When an instance of a Case object is created, CaseInfo is simply null; it doesn't contain a default CaseInfo object. What is the syntax for setting the defaults of such an object?

like image 733
Paul Carlisle Avatar asked Mar 15 '26 16:03

Paul Carlisle


1 Answers

It looks like you can initialize default values for structs via a json style map of field names to values. E.g.

struct Case{
    1: CaseInfo CaseInfo = {"CaseID": "", "EvID": "foobar"},
    2: string key = ""
}
like image 81
David Avatar answered Mar 19 '26 14:03

David



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!