Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6591635
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:26:59+00:00 2026-05-25T17:26:59+00:00

I am struggling with finding any good examples of coffeescript and pattern matching apart

  • 0

I am struggling with finding any good examples of coffeescript and pattern matching apart from these sort of examples:

{x, y} = sprite
css = {opacity, fontFamily}

I have used pattern matching in Erlang but I am struggling with finding some more advanced examples in coffeescript which illustrate exactly what is possible.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T17:27:00+00:00Added an answer on May 25, 2026 at 5:27 pm

    Ah, I thought I recognized those examples: http://pragprog.com/magazines/2011-05/a-coffeescript-intervention 🙂

    CoffeeScript’s pattern-matching (more formally called “destructuring assignment” to distinguish it from pattern-matching in Erland and Scala, which is quite different) can be used to extract information from very elaborate data structures. Here’s an example from the official docs:

    {poet: {name, address: [street, city]}} = futurists
    

    which is essentially equivalent to

    poet = futurists.poet
    name = poet.name
    street = poet.address[0]
    city = poet.address[1]
    

    In practice, though, destructuring assignment is mainly used for grabbing one or two object properties, as in the examples you mentioned, or for getting parts from an array. For instance, you can swap the values of two variables a and b by writing

    [a, b] = [b, a]
    

    and, using splats, you can get the first and last values of an array arr by writing

    [first, middle..., last] = arr
    

    I hope that helps. There are of course more examples in my book, CoffeeScript: Accelerated JavaScript Development.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm struggling finding a proper way of retrieving proper results from my mysql table.
I'm trying to learn EF in visual basic. I'm struggling with finding any easy
I'm designing a new system and finding that I am struggling with the structure
So I have been struggling with finding a decent C# library to use with
I am new to SQL and struggling with finding a working solution for my
Whilst there are many good examples on this forum that contain examples of coupling
I'd like to know if there are any good EF providers for Oracle out
I'm struggling to write a xpath which will help me finding image for popup.gif
I'm struggling with finding out if a MKPolygon intersects with a MKCircle. This is
Currently struggling with PHP and creating KML from it. I'm using the last.fm API

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.