Giter Site home page Giter Site logo

Returns the same result for [] and {} about crimp HOT 2 OPEN

jcward avatar jcward commented on September 15, 2024
Returns the same result for [] and {}

from crimp.

Comments (2)

samfrench avatar samfrench commented on September 15, 2024

Hi @jcward, not too sure about this one. I agree if stringify'ing a hash then returning 'Array' is misleading, but I don't think this is main point of this. Stringify is used to just turn any object into a string. When you use sort on a hash you get an array back anyway, but that is another point.

Are you currently using stringify and need 'Hash' returned? If you need the type then I'd use {}.class which would be accurate.

I would make the stringify method private to allow the signature method only, but people might be consuming the stringify method now. If there is a need to specify Hash when using an original Hash then this can be looked at, but there is a reason why turning the Hash into an Array is implemented.

from crimp.

jcward avatar jcward commented on September 15, 2024

I'm just using stringify because it's easier to see what's happening under the hood than signature's hex output. Their equivalence is interchangeable (having the same string == having the same signature).

The jist of this issue is that Crimp considers [] the exact same as {} -- maybe that's the intent. Also, [{}] is the same as [[]], and {:foo=>[]} as {:foo=>{}}.

This issue is more about letting people know what they're getting with Crimp. Feel free to close as "as-designed".

For me, I expected a unique signature per any object I input. I wouldn't think [] == {} so I was surprised.

from crimp.

Related Issues (2)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.