Scala - User - Second constructor parameter list [PDF]

Second constructor parameter list. Hello, I was trying to do something like this in Scala 2.12: class Watcher(directory:

13 downloads 25 Views 53KB Size

Recommend Stories


Manualul inginerului constructor pdf
Courage doesn't always roar. Sometimes courage is the quiet voice at the end of the day saying, "I will

PdF Scala Cookbook
And you? When will you begin that long journey into yourself? Rumi

Scala Sockelleisten Scala Skirts
You often feel tired, not because you've done too much, but because you've done too little of what sparks

M.Com Second Admission List
You have to expect things of yourself before you can do them. Michael Jordan

provisional second selection list
Pretending to not be afraid is as good as actually not being afraid. David Letterman

Carleman estimates with second large parameter for second order operators
No amount of guilt can solve the past, and no amount of anxiety can change the future. Anonymous

Code Cube Constructor
So many books, so little time. Frank Zappa

M.Sc. Mathematics Second Admission List
Do not seek to follow in the footsteps of the wise. Seek what they sought. Matsuo Basho

M.Sc. Mathematics Second Admission List
Don’t grieve. Anything you lose comes round in another form. Rumi

Second Merit List (Gujarati Medium)
If you feel beautiful, then you are. Even if you don't, you still are. Terri Guillemets

Idea Transcript


Scala Language › Scala - User

Login Register

Second constructor parameter list ‹ Previous Topic

Next Topic



Classic

List

Jakub Janeček

4 messages

Threaded Jan 13, 2017; 10:05pm

Second constructor parameter list

Options

Reply | Threaded | More

Hello, I was trying to do something like this in Scala 2.12:

2 posts

class Watcher(directory: Path)(listener: () => Unit) extends AutoCloseable { ... } val watcher = new Watcher(Paths.get("")) { () => ... } However I am getting the following compiler error: Error:(39, 43) missing argument list for constructor Watcher in class Watcher val watcher = new ConfigDirectoryWatcher(configFilesDirectory) { () => Could someone please try to explain it to me? I don't understand why this does not compile. It can be fixed by surrounding the code with parentheses and moving the braces inside them. I think I used to write such code just fine before so that would mean that it stopped working since Scala 2.12 but I don't know why. Thanks for any answer. Regards, -Jakub Janeček -- You received this message because you are subscribed to the Google Groups "scala-user" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. For more options, visit https://groups.google.com/d/optout.

som-snytt

Jan 21, 2017; 11:52am

Re: Second constructor parameter list

Reply | Threaded | More

http://scalapuzzlers.com/#pzzlr-036 An apply method can take a block expression, so maybe that is what seems familiar. 490 posts

scala> import java.nio.file._ import java.nio.file._ scala> case class C(p: Path)(f: () => Unit) defined class C scala> C(Paths.get("")){() => ()} res0: C = C()

On Friday, January 13, 2017 at 7:07:19 AM UTC-8, Jakub Janeček wrote:

Hello, I was trying to do something like this in Scala 2.12: class Watcher(directory: Path)(listener: () => Unit) extends AutoCloseable { ... } val watcher = new Watcher(Paths.get("")) { () => ... } However I am getting the following compiler error: Error:(39, 43) missing argument list for constructor Watcher in class Watcher val watcher = new ConfigDirectoryWatcher(configFilesDirectory) { () => ... [ show rest of quote]

Could someone please try to explain it to me? I don't understand why this does not compile. It can be fixed by surrounding the code with parentheses and -- moving the braces inside them. I think I used to write such code just fine before so that would mean that it stopped working since Scala 2.12 but I don't know why. You received this message because you are subscribed to the Google Groups "scala-user" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. Thanks for any answer. Regards, For more options, visit https://groups.google.com/d/optout.

Roman Janusz

-Jan 22, 2017; 7:15pm Re: Second constructor parameter list Jakub Janeček

Reply | Threaded | More

In reply to this post by Jakub Janeček

Essentially, the problem is that the compiler thinks that you're defining an anonymous class and the braces denote the body of that class. You need to put that argument into regular parentheses.

65 posts

W dniu piątek, 13 stycznia 2017 16:07:19 UTC+1 użytkownik Jakub Janeček napisał:

Hello, I was trying to do something like this in Scala 2.12: class Watcher(directory: Path)(listener: () => Unit) extends AutoCloseable { ... } val watcher = new Watcher(Paths.get("")) { () => ... } However I am getting the following compiler error: Error:(39, 43) missing argument list for constructor Watcher in class Watcher val watcher = new ConfigDirectoryWatcher(configFilesDirectory) { () => ... [ show rest of quote]

Could someone please try to explain it to me? I don't understand why this does not compile. It can be fixed by surrounding the code with parentheses and -- moving the braces inside them. I think I used to write such code just fine before so that would mean that it stopped working since Scala 2.12 but I don't know why. You received this message because you are subscribed to the Google Groups "scala-user" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. Thanks for any answer. Regards, For more options, visit https://groups.google.com/d/optout.

Jakub Janeček

-Jan 23, 2017; 2:40pm Re: Second constructor parameter list Jakub Janeček

Reply | Threaded | More

Oh right, thanks, I didn't see that. On Sunday, January 22, 2017 at 1:16:23 PM UTC+1, Roman Janusz wrote: Essentially, the problem is that the compiler thinks that you're defining an anonymous class and the braces denote the body of that class. You need to put that argument into regular parentheses. 2 posts

W dniu piątek, 13 stycznia 2017 16:07:19 UTC+1 użytkownik Jakub Janeček napisał:

Hello, I was trying to do something like this in Scala 2.12: class Watcher(directory: Path)(listener: () => Unit) extends AutoCloseable { ... } val watcher = new Watcher(Paths.get("")) { () => ... } However I am getting the following compiler error:

... [ show rest of quote]

Error:(39, 43) missing argument list for constructor Watcher in class Watcher

-- val watcher = new ConfigDirectoryWatcher(configFilesDirectory) { () => You received this message because you are subscribed to the Google Groups "scala-user" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. ... [ show rest of quote] Could someone please try to explain it to me? I don't understand why this does not compile. It can be fixed by surrounding the code with parentheses and For more options, visit https://groups.google.com/d/optout.

moving the braces inside them. I think I used to write such code just fine before so that would mean that it stopped working since Scala 2.12 but I don't know why.

« Return to Scala - User | 109 views

Thanks for any answer. Regards, -Jakub Janeček

Free forum by Nabble - Scala Resume Examples - Resume Templates

Disable Popup Ads | Edit this page

Smile Life

When life gives you a hundred reasons to cry, show life that you have a thousand reasons to smile

Get in touch

© Copyright 2015 - 2024 PDFFOX.COM - All rights reserved.