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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T08:06:07+00:00 2026-05-31T08:06:07+00:00

I have 3 Scala classes (A,B,C). I have one implicit conversion from A ->

  • 0
  • I have 3 Scala classes (A,B,C).
  • I have one implicit conversion from A -> B and one from B -> C.

At some point in my code, I want to call a C method on A. Is this possible?
One fix I came up is to have a conversion from A -> C but that seems somewhat redundant.

Note:

  • When I call B methods on A it works.
  • When I call C methods on B it works.
  • When I call C methods on A it says that it didn’t find the method in the body of A

Thanks …

  • 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-31T08:06:09+00:00Added an answer on May 31, 2026 at 8:06 am

    It does seem somewhat redundant, but the A -> C conversion is exactly what you should supply. The reason is that if implicits are rare, transitive chains are also rare, and are probably what you want. But if implicits are common, chances are you’ll be able to turn anything into anything (or, if you add a handy-looking implicit, suddenly all sorts of behaviors will change because you’ve opened up different pathways for implicit conversion).

    You can have Scala chain the implicit conversions for you, however, if you specify that it is to be done. The key is to use generics with <% which means “can be converted to”. Here’s an example:

    class Foo(i: Int) { def foo = i }
    class Bar(s: String) { def bar = s }
    class Okay(b: Boolean) { def okay = b }
    implicit def to_bar_through_foo[T <% Foo](t: T) = new Bar((t: Foo).foo.toString)
    implicit def to_okay_through_bar[U <% Bar](u: U) = new Okay((u: Bar).bar.length < 4)
    
    scala> (new Foo(5)).okay
    res0: Boolean = true
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to extend multiple classes in Scala. For example if I have
I have created a project that uses scala that has some abstract classes definitions
I have this method: scala> def foo(traversable: Traversable[{def toByte: Byte}]) = { | traversable.map(_.toByte)
I'm studying the source code of the Scala 2.8 collection classes. I have questions
Say I have four sub-classes of 'Car'. One for each color. I want to
I have few classes and functions in java code. one of the function is
Newbie Scala Question: Say I want to do this [Java code] in Scala: public
Does Scala have a version of Rubys' each_slice from the Array class?
Let's say I have this Hello.scala. object HelloWorld { def main(args: Array[String]) { println(Hello,
I am one step away from making the method described here: Targeting Android with

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.