Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Quirk with LiveScript's dash-to-camelCase conversion in cursor paths #81

@chrisvfritz

Description

@chrisvfritz
# Given a cursor where a key is defined with dashes
data = arch.cursor do
  name-with-dashes: 'value'

# Trying to grab the name using a string with dashes will not work, because 
# although non-literal object keys are transformed to camelCase in LiveScript, 
# dashes in string literals are not
data.get \name-with-dashes .deref! # => null

# To correctly find the name, you have to use the camelCased string that 
# LiveScript converts the key to:
data.get \nameWithDashes .deref! # => "value"

This isn't technically a bug - just how LiveScript works. But I can see a lot of people, especially those new to LiveScript (which may even be most people using LiveScript in Arch), tripping over it. I think a good solution might be to always camelCase the string passed to get unless a non-null value exists for the non-camelCased version. Thoughts?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions