Sly
Sly

Reputation: 733

Reference an object property that has "." in it's name

I'm attempting to reference an object property that has a . in the name. So, for example, in fdb if I have an object:

MyObject target.property

If I attempt to "print":

fdb> print MyObject.target.property

I get:

Variable target.property unknown

How do I access this property and look at it's contents given that it's name is target.property

Upvotes: 0

Views: 320

Answers (2)

cwallenpoole
cwallenpoole

Reputation: 82028

It is generally a bad idea to have . as part of a property name, but it can be gotten by:

var val = MyObject[ "target.property" ]

That is called "array notation". It is slower and buggier than the correct way to address a property. It also allows for the introduction of a number of potential bugs and difficulties in diagnosis but, in cases where you don't have control of the input, it will be sufficient.

Upvotes: 3

Bart van Heukelom
Bart van Heukelom

Reputation: 44104

MyObject["target.property"]

Upvotes: 0

Related Questions