Hello, looks like the
export clause does not exports the default values of a function's parameters. Using Scala 3.1.1-RC1 on
class A(s: String): def greeting(name: String = s) = s"Hello $name" class B: val a = A("You") export a.* val b = B() println(b.a.greeting()) // works println(b.greeting("John")) // works println(b.greeting()) // nope !
Is it a known restriction ?
getLinesso you can load all the data in memory an being able to use it multiple times.
typeSignature, I get the following for
=> Int. I want to inspect using something like
in =:= typeOf[Int]. I'm a bit confused on what i should be doing?
List[List[Any]]where the inner list always has two elements of different types; use a
thought it was a dumb question to ask
There are no dumb questions, there are fools that don't ask.
Is it bad to have a for loop that wouldn't yield a value but instead change a predefined array?
Well, it depends on a lot of things, specially what is your definition of "bad".
I just want to learn the functional way of coding, Thank you for the information and for the example
No worries and welcome to the community!
type Id = Int | Long | UUID trait MappedTo[+T <: Id] extends Any: def value: T type GetType[T <: MappedTo[_]] = T match case MappedTo[Int] => Int case MappedTo[Long] => Long case MappedTo[UUID] => UUID class Extract[T <: MappedTo[_]](val map: T => GetType[T]) given extract[T <: MappedTo[_]]: Extract[T] = new Extract[T](_.value) // ERROR
| Required: GetType[T²]
| where: T is a type in trait MappedTo with bounds <: Id
| T² is a type in given instance extract with bounds <: MappedTo[?]
| Note: a match type could not be fully reduced:
| trying to reduce GetType[T]
| failed since selector T
| does not match case MappedTo[Int] => Int
| and cannot be shown to be disjoint from it either.
| Therefore, reduction cannot advance to the remaining cases
| case MappedTo[Long] => Long
| case MappedTo[java.util.UUID] => java.util.UUID
val map: T => GetType[T], T is unknown and therefore the match type fails.
I guess I'm looking for a lazy Match Type if that makes sense, or is even possible.
I just found some interesting behavior in Scala 3.
infix case class ~( ) def main(): Unit = val ab: Int ~ Int = ~(1, 3) println(ab)
value unary_~ is not a member of (Int, Int). In other words,
~(1, 3) is getting parsed as
Tuple2(1, 3) instead of
function name ~ + arguments
(1, 3). Is this a change in how Scala 3 parses, a known bug, or have I discovered something interesting?
~.apply(1, 3)seems to work as a workaround, but is a little annoying.
~ is already defined as object ~ in /path/to/the/scala/file
Hello there! I just started poking around with Scala and
sbt, but am running into some gnarly errors right out of the box that I'm finding hard to diagnose.
First, I installed
sbt via Homebrew (I'm on OSX) and followed the instructions in this example project: https://github.com/tototoshi/sbt-hot-reload-example
At first, it worked like a charm. Then I came back to it a few minutes later, did another
cd framework && sbt publishLocal && cd ../app && sbt run, and got the following error:
INFO: No global web.xml found Dec 06, 2021 7:08:26 PM org.apache.tomcat.util.scan.StandardJarScanner processURLs WARNING: Failed to scan [file:/Users/ths/.sbt/boot/scala-2.12.14/org.scala-sbt/sbt/1.5.5/scala-reflect.jar] from classloader hierarchy java.io.IOException: java.lang.reflect.InvocationTargetException at org.apache.tomcat.util.compat.Jre9Compat.jarFileNewInstance(Jre9Compat.java:209) at org.apache.tomcat.util.scan.JarFileUrlJar.<init>(JarFileUrlJar.java:65) at org.apache.tomcat.util.scan.JarFactory.newInstance(JarFactory.java:49) at org.apache.tomcat.util.scan.StandardJarScanner.process(StandardJarScanner.java:383) at org.apache.tomcat.util.scan.StandardJarScanner.processURLs(StandardJarScanner.java:318) at org.apache.tomcat.util.scan.StandardJarScanner.doScanClassPath(StandardJarScanner.java
Like it's looking for a JAR but not finding it.
sbt, installing it via
sdkinstead, but to no avail.
importstatements in Scala 3? I checked the
implicit-resolutiondocument but that does not seem very enlightening.
Hey there, I'm having an odd problem with taking user input in the terminal. I'm using
scala.io.StdIn.readLine() method to prompt the user for interaction but it doesn't work as expected. I can type something in and press ENTER but nothing happens afterwards. Looks like everything after the
readLine() is not being called anymore.
I'm on Ubuntu 18.04 LTS using Java 11 and Scala 2 and 3. I also tried to google the problem but I couldn't find a solution yet. I was hoping that someone here had the same strange issue and might have a solution.