Giter Club home page Giter Club logo

p6-symbol's Introduction

Build Status

NAME

Symbol - Port of Javascript's Symbol primitive type

SYNOPSIS

use Symbol;

say Symbol('ayy lmao');                                # OUTPUT: Symbol('ayy lmao')
say Symbol('ayy lmao')     =:= Symbol('ayy lmao');     # OUTPUT: False
say Symbol.for('ayy lmao') =:= Symbol.for('ayy lmao'); # OUTPUT: True

DESCRIPTION

Symbol is a port of Javascript's Symbol primitive type. This implements creating Symbol instances, but not the behaviour of well-defined symbols.

Symbol's purpose is to provide a way to create objects that are guaranteed to be unique. Optionally, they can be provided with a description, which is mainly used when stringifying them.

ATTRIBUTES

  • Str $.description

The description of the symbol. This is the string passed to Symbol.CALL-ME or Symbol.for.

METHODS

  • method CALL-ME(Symbol:U: Str $description? --> Symbol:D)

Creates a new symbol given $description.

Though its signature states that the description is optional, Symbol() does not create a symbol with no description; that actually ends up being a type coercion. To create a symbol with no description, use Symbol(Nil).

  • method for(Symbol:U: Str $description? --> Symbol:D)

If no symbol instantiated using Symbol.for already exists, creates a new symbol given $description, otherwise returns the one that already exists.

  • method gist(Symbol:D: --> Str:D)

Stringifies the symbol like in Javascript.

  • method Str(Symbol:D: --> Str:D)

Stringifies the symbol like in Javascript.

  • method perl(Symbol:D: --> Str:D0

Stringifies the symbol like in Javascript.

AUTHOR

Ben Davies (Kaiepi)

COPYRIGHT AND LICENSE

Copyright 2019 Ben Davies

This library is free software; you can redistribute it and/or modify it under the Artistic License 2.0.

p6-symbol's People

Contributors

kaiepi avatar

Watchers

James Cloos avatar  avatar

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.