Scala Users
7 FOLLOWERS
Share your knowledge and communicate about Scala in this forum. Discuss variable type arguments, Method interception, AOP in Scala, and more. Also, shoot your questions if you have one and get them answered by experts / enthusiasts here.
Scala Users
2d ago
The Scala team at Lightbend is proud to announce Scala 2.13.14.
This release improves cross-building with Scala 3, fixes a few regressions, and more.
For details, refer to the release notes on GitHub.
1 post - 1 participant
Read full topic ..read more
Scala Users
2d ago
I have this error while trying to instantiate an object of type Global in Scala 2.12.19 with JDK 17.
object java.lang.Object in compiler mirror not found
It used to work with Scala 2.12.6 and JDK 8.
I tried to solve the error by adding settings but that didn’t help :
compilerSettings.processArgumentString(“–release:17 --target:17”)
The full stack trace is :
scala.reflect.internal.MissingRequirementError: object java.lang.Object in compiler mirror not found.
at scala.reflect.internal.MissingRequirementError$.signal(MissingRequirementError.scala:24)
at scala.reflect.internal.MissingRequirem ..read more
Scala Users
2d ago
Hello everyone, I’m trying to create a method to access the concrete type of type parameters of a class.
import scala.reflect.runtime.universe._
abstract class BaseClass
class A[T](a: T) extends BaseClass
class B[T, U](a: T, b: U) extends BaseClass
class C[T, U]() extends BaseClass
// Get the parametrics of a given instance x
def getConstructorParametrics[T](x: T)(implicit wtt: WeakTypeTag[T]): Seq[String] = {
wtt.tpe match {
case TypeRef(utype, usymbol, args) => args.map(_.toString.replaceAll(",(?! )", ", "))
}
}
This method works but only if I call it directly:
getConstruct ..read more
Scala Users
1w ago
Greetings all!
First of all, I’m relatively new to Scala, so I’m sorry if I commit any naming mistake, and you may consider anything here as passible for change, refactoring or even total reconsideration of my own
I’ve been working on a personal project in Scala 2.12.19, aiming to create unit tests for most of it. In order to retrieve the content of system files, I’ve decided to use the Java API java.nio.file, which I’ve heard is faster and more secure, without needing to close the access, which is a valid advantage for my project. I’ve imported the Files and Path classes, both Java static cl ..read more
Scala Users
1w ago
Hello everyone,
I’m working on learn the Scala3 but I’m not sure which way is fix for my program. Can someone explain basicly and give me some advice for my project.
Problem: I want to save my log for if a user want to see old info so I’ll put a section 4 in my promth then user can show logs.
@main
def main() = {
userui()
}
def userui(): Unit = {
var continue = true
while (continue) {
println(“*************************\n" +
" Weather Calculation **********\n” +
" 1. Fahrenheit \n" +
" 2. Celsius \n" +
" 3. Exit \n" +
" =========================================" )
val selection = readIntSafely ..read more
Scala Users
1w ago
Is there a way to load a scala file into the Scala 3 REPL on startup?
I know after startup I can say :l myfile.scala, but when I start the Scala REPL on the command line:
$ scala --explain
I often know already that I want to load myfile.scala.
4 posts - 3 participants
Read full topic ..read more
Scala Users
1w ago
Hello everyone. I wrote the following method to obtain the parameters in the constructor of a class:
/** Get the parameters in the constructor of a given scala class.
*
* Returns a list of tuples with the name as first and the type of the parameter as second.
*/
def getConstructorParams(target: Any): Seq[(String, String)] = {
import scala.reflect.runtime.universe._
import scala.reflect.api.{Mirror, TypeCreator, Universe}
val c = target.getClass
val mirror = runtimeMirror(c.getClassLoader) // obtain runtime mirror
val sym = mirror.staticClass(c.getName) // obt ..read more
Scala Users
1w ago
By popular demand , I have released a new version:
added compatibility with scala.js, see Tessella _sjs1_3
added to the toSVG(...) method an option to visualize the inversion of a tessellation
1 post - 1 participant
Read full topic ..read more
Scala Users
1w ago
I can define
def answerToAllQuestions() : int =
42
and call it val answer = answerToAllQuestions()
Then I can define
def answerToAllQuestions : int =
42
and I cannot call it the same way:
val answer = answerToAllQuestions()
gives me “Syntax Error: method answerToAllQuestions does not take parameters”.
Why’s that? answerToAllQuestions() shows indeed that there are no parameters…
Although I do understand that the text of the definitions is different, I think the type signatures of both functions are the same and should make the use of the functions indistinguishable…
Bonus question: Wh ..read more
Scala Users
1w ago
Say I instantiate an HList so (compiles correctly:
val ff1b: ICons["5", 5, IEmpT] = ICons("5", 5, IEmpT)
summon[ff1b.type <:< ICons["5", 5,IEmpT]]
If I use the following run-time checks:
assert(ff1b.isInstanceOf[ICons[String, Int, IEmpT]])
assert(ff1b.isInstanceOf[ICons["5", 5, IEmpT]])
I get the error:
[warn] 619 | assert(ff1b.isInstanceOf[ICons[String, Int, IEmpT]])
[warn] | ^^^^
[warn] |the type test for icollection.IMap.ICons[String, Int, icollection.IMap.IEmpT] cannot be checked at runtime because its type arguments can't be determined from ..read more