Skip to content
This repository has been archived by the owner on Nov 23, 2017. It is now read-only.

No way to access string fields on objects #200

Open
reynir opened this issue Oct 1, 2013 · 0 comments
Open

No way to access string fields on objects #200

reynir opened this issue Oct 1, 2013 · 0 comments

Comments

@reynir
Copy link

reynir commented Oct 1, 2013

For example it's impossible to access the 'foo/bar' field on the following object

let a = { 'foo/bar' : 42 } // It's impossible to access a['foo/bar']

In general you can't access the fields if you

  1. Don't know the key in advance, or
  2. The key isn't a valid identifier (ex. 'foo/bar')

A "workaround" is to use eval:

let a = { 'foo/bar' : 42 }
let x = eval 'a["foo/bar"]'

It's not pretty and requires that the identifiers are "stable".

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant