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

  • Home
  • SEARCH
  • 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 6384973
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:50:29+00:00 2026-05-25T02:50:29+00:00

In my base class I have trait EventReceiver { def onStart(start: Start) { }

  • 0

In my base class I have

  trait EventReceiver  {

    def onStart(start: Start) {

    }

  }

I define

  def benchmark = new EventReceiver {}

since I need to do some processing in the base class. In the child class which my clients use they do something similar to the following

override def benchmark = new EventReceiver {
    override def onStart(start: Start) {
      println("benchmark start")
    }
}

I view this bit as a bit clunky

override def benchmark = new EventReceiver { ...

Is there a nicer way to express this? Ideally it would be something like

singleword {
    override def onStart(start: Start) {
      println("benchmark start")
    }
}
  • 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-25T02:50:29+00:00Added an answer on May 25, 2026 at 2:50 am

    For example,

    def singleword(fOnStart: Start => Unit) =
      new EventReceiver {
        override def onStart(start: Start) { fOnStart(start) }
      }
    

    then,

    singleword { start =>
      println("benchmark started")
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say we have: class Base { virtual void f() {g();}; virtual void g(){//Do some
I have a class using operator overloading, but there are some warnings. // base.h
I have some Base class in c++. I export it into python using boost::python.
Let's say in some abstract ViewModel base-class I have a plain-old property as follows:
In my base class I have a generic method (ideally this would be a
I have a base class where I derive several classes. I have another class
I have base class BaseClass and derived classes DerivedA , DerivedB , and DerivedC
I have a abstract base class that I have many inherited classes coming off
I have a class Contact (base class),a class called Customer and a class called
I have a class (Descendant1) that inherits from a base class (BaseClass). An instance

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.