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

The Archive Base Latest Questions

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

Hi I read the interesting post from Debasish about the implicitly function. I have

  • 0

Hi I read the interesting post from Debasish about the implicitly function. I have wrote this code:

def find[C <: Business](id: String) = {
  collection.findOneByID(id).map(x=> implicitly[DBObject => C].apply(x))
}

but it fails to compile with this compiler message:

could not find implicit value for parameter e: (com.mongodb.casbah.commons.Imports.DBObject) => C

what is my fault? anyone can help me?

UPDATE

My idea was this:
find is declared in a trait don’t know nothing about DBObject, I don’t want to put this dependency.

 trait BusinessRepository {
   def find[C <: Business](id: String): Option[C]
 }

class MongoBusinessRepository {

  val collection = ..

  def find[C <: Business](id: String): Option[C] = {
    collection.findOneByID(id).map(x=> implicitly[DBObject => C].apply(x))         
  }

  implicit def DBObject2Hotel(x: DBObject): Hotel = {
    // ... 
    // returning Hotel
  }
}

case class Hotel(...) extends Business(...)
  • 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-27T02:35:51+00:00Added an answer on May 27, 2026 at 2:35 am

    implicitly is just a convenience method to look up an implicit value that you know already exists. So it fails to compile when there is no such implicit value in scope.

    A possible use case is when you use shortcut syntax for context bounds:

    def find[C: Numeric](a: C, b: C): C = implicitly[Numeric[C]].plus(a, b)
    

    Of course, in this example, the explicit form is less verbose

    def find[C](a: C, b: C)(implicit n: Numeric[C]): C = n.plus(a, b)
    

    You will find more thorough explanations in this Stackoverflow thread.


    What I imagine you had in mind with your method is rather

    def find[C <: Business](id: String)(implicit fun: DBObject => C) =
      collection.findOneByID(id).map(fun)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just read this interesting article about the implementation details for various languages
I have read an interesting article about css selector profiling but I haven't found
I have read this post and I wanted to use ControllerExtensions.RedirectToAction method. But I
I read an interesting DailyWTF post today, Out of All The Possible Answers... and
I read This article and i found it interesting. To sum it up for
Read about Server push here . I want to push data to client from
Well I was reading this post and then I came across a code which
I recently read an interesting blog post on Anders Hejlsberg's arguments against AOP. The
I just read this rather interesting article, Copying Accelerated Video Decode Frame Buffers .
Today I read abouts this on hacker news https://github.com/udibr/bitcoinApp which is an interesting app,

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.