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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T02:48:32+00:00 2026-05-24T02:48:32+00:00

I have got a class with many methods. class C{ def f1(x:String,….):…=.. def f2(..)…

  • 0

I have got a class with many methods.

class C{
def f1(x:String,....):...=..
def f2(..)...
.
.
.

}

I want now that every method defined in my class is decorated with a trait of my choice automatically.
Something like to create a tricky implicit ore something what decorates every method and perhaps returns an instance of the class with decorated methods. Perhaps wrapped or modified or something. I can not describe more of the way because i dont know the way.
Do you know a way to do that?

  • 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-24T02:48:33+00:00Added an answer on May 24, 2026 at 2:48 am

    Methods are not functions, although they will automatically be lifted when you pass them to a method that requires a function. See also http://jim-mcbeath.blogspot.com/2009/05/scala-functions-vs-methods.html

    If you really have functions:

    class C {
      val f1 = (x: String, ...) =>
      val f2 = (...) =>
      ...
    }
    

    and you want them to mix in a trait, like:

    class C {
      val f1 = new FunctionN[String, ...] with Gaga {
        def apply(s: String, ...) = ...
      }
      val f2 = new FunctionN[...] with Gaga { ... }
      ...
    }
    

    the only way I can think of is submit your class to something like Scala-Refactoring: http://scala-refactoring.org/

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

Sidebar

Related Questions

I have a class and got a method that doin so many things in
I've got a class with many string arrays. I'd like to have one generic
Just want to check: If you have a class that uses a method added
I have got a designing dilema. I have a class named UserAccount that represent
I've got a class that contains (among many other things) a list of items
I have a specific situation where I've got an object that I want to
I have a method in my country.rb where I defined a new method. class
I have got a template class as follows: class MyClass<T> { T field; public
I have got the following class structure, and have plenty of classes like C
I've got the class object for an enum (I have a Class<? extends Enum>

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.