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 7189799
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T19:22:43+00:00 2026-05-28T19:22:43+00:00

When building a class in CoffeeScript, should all the instance method be defined using

  • 0

When building a class in CoffeeScript, should all the instance method be defined using the => (“fat arrow”) operator and all the static methods being defined using the -> operator?

  • 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-28T19:22:44+00:00Added an answer on May 28, 2026 at 7:22 pm

    No, that’s not the rule I would use.

    The major use-case I’ve found for the fat-arrow in defining methods is when you want to use a method as a callback and that method references instance fields:

    class A
      constructor: (@msg) ->
      thin: -> alert @msg
      fat:  => alert @msg
    
    x = new A("yo")
    x.thin() #alerts "yo"
    x.fat()  #alerts "yo"
    
    fn = (callback) -> callback()
    
    fn(x.thin) #alerts "undefined"
    fn(x.fat)  #alerts "yo"
    fn(-> x.thin()) #alerts "yo"
    

    As you see, you may run into problems passing a reference to an instance’s method as a callback if you don’t use the fat-arrow. This is because the fat-arrow binds the instance of the object to this whereas the thin-arrow doesn’t, so thin-arrow methods called as callbacks as above can’t access the instance’s fields like @msg or call other instance methods. The last line there is a workaround for cases where the thin-arrow has been used.

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

Sidebar

Related Questions

I'm building a class library that will have some public & private methods. I
I'm building a C# class library, and using the beta 2 of Visual Web
I am building a class library and using its default namespace as System. There
I'm currently building a class in PHP that generates PDF documents using the WKHTMLTOPDF
What should I be careful about when building a class library complex enough to
I'm building a class project (seperate dll) that will contain various helper methods and
I'm currently building a class using TDD. The class is responsible for waiting for
I'm using prototype 1.7 and building a class that will essentially take a list
I'm building a class that automatically loads a DB record, looks at each DB
I am building a class that handles NSURLConnection requests. To allow other classes to

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.