Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Jul 19 20:37
    @SethTisue banned @tonyobanon
  • Jan 02 23:58
    @SethTisue banned @fakubishes:nerdsin.space
  • Dec 15 2021 05:01
    som-snytt commented #12516
  • Dec 15 2021 04:38
    SethTisue edited #1312
  • Dec 15 2021 04:38
    SethTisue opened #2273
  • Dec 15 2021 04:31
    jackkoenig opened #12516
  • Dec 15 2021 04:29
    SethTisue edited #1312
  • Dec 15 2021 04:28
    SethTisue edited #1312
  • Dec 15 2021 04:27
    SethTisue labeled #9831
  • Dec 15 2021 04:27
    scala-jenkins milestoned #9831
  • Dec 15 2021 04:27
    SethTisue labeled #9831
  • Dec 15 2021 04:27
    SethTisue opened #9831
  • Dec 15 2021 03:35
    som-snytt commented #11339
  • Dec 15 2021 03:27
    som-snytt labeled #12494
  • Dec 15 2021 03:07
    SethTisue edited #1312
  • Dec 15 2021 03:07
    SethTisue edited #1312
  • Dec 15 2021 03:05
    SethTisue edited #1312
  • Dec 15 2021 03:05
    SethTisue edited #1312
  • Dec 15 2021 03:05
    SethTisue edited #1312
  • Dec 15 2021 02:58
    SethTisue edited #1312
Luis Miguel Mejía Suárez
@BalmungSan
How did you expect it to be visible if it was not in the same package?
daymo
@daymo
@BalmungSan I run the code with Mill v0.9.10
Luis Miguel Mejía Suárez
@BalmungSan
@daymo maybe that is the problem? I just tried with the plain compiler and it works.
Try putting that in a file called ConsoleApp.scala in a folder alone.
And then run:
scalac ConsoleApp.scala
scala ConsoleApp
And let me know if it runs as expected.
daymo
@daymo
@BalmungSan Hmm, that actually works as it is supposed to and that narrows the problem down even more. Any idea why running it with Mill would make such a huge difference? I will consult the Mill channel anyway...
Luis Miguel Mejía Suárez
@BalmungSan
Yeah all I know about Mil is its name and the name of its creator lol.
So yeah, the best is to consult there.
:) :wave:
daymo
@daymo
@BalmungSan No worries and thank you for your help.
Derek Willingham
@DirtySoc
I am completely new to Scala and SBT. I am trying to setup a built.sbt file so that sbt publish will push the maven style project to one remote repository if the build agent is a Jenkins and a different remote repository if the build agent is a GitHub action. I've spent about 6 hours on this today and I don't feel like I really understand much more about SBT and how to modify the behavior of sbt publish. Does anyone here have good example sbt projects or suggestions for learning more in regard to what I am trying to do?
Also are Seq() and Some() special sbt functions? I see those throughout the build.sbt files I have been looking at and I don't really know what they do.
Luis Miguel Mejía Suárez
@BalmungSan
So you don't even know basic Scala and yet you want to do a custom publishing which seem very complex (if even possible) to do...
I think you would need more help.
Anyways, you may want to ask in the #tooling channel of the discord server.
Luis Miguel Mejía Suárez
@BalmungSan
BTW according to the docs you should be able to do something like this:
publishTo := { if (isJenkins) Some(...) else Some(...) }
Now, not sure how are you going to check which is the runner.
2 replies
Alex
@unthingable
Question about transparent inlining: I have a value x and a deserialized class object o fetched from a database. The fetch is polymorphic in that the object can be one of two distinct types, I don't know which one ahead of time. o has a method .foo(x) that expects a specific type of a value, depending on the type of o, and for that it has a safeguard method transparent inline cast[A](a: A) = inline erasedValue[A] match {...}. The question: given that the object is only known at runtime, is inlining going to do any good, or am I grossly misunderstanding it?
Luis Miguel Mejía Suárez
@BalmungSan
@DirtySoc so it seems you could do this:
publishTo := {
  scala.util.Properties
    .envOrNone(name = "GithubRunnerEnvVar")
    .fold(ifEmpty = Some(jenkinsRepository)) { _ =>
      Some(githubActionsRepository)
    }
southrivers
@southrivers
import java.lang.{Byte => JByte}
any one know what does this mean?
ml10
@ml10
I’m not sure ther precise name, but I’ve seen it referred to as a “rename import” or “import rename”. https://alvinalexander.com/scala/how-to-rename-members-import-scala-classes-methods-functions/
southrivers
@southrivers
thanks very much
megri
@megri
Is there a way to build a Map[K, V] by using the builders pattern, where I need to update a map key with a new value as I go along?
Basically what I want is items.foreach(item => mapBuilder.updateOrSet(item.key, set = 0, update = n => n + 1))
Luis Miguel Mejía Suárez
@BalmungSan
@megri you can do this:
items.foldLeft(Map.empty[K, V]) {
  case (acc, item) =>
    acc.updatedWith(key = item.key) {
      case Some(n) => Some(n + 1)
      case None => Some(0)
    }
}
No need to mutate.
Also, this seems it is doing some kind of word-count or something similar, right?
You should be able to just:
items.groupMapReduce(_.key)(_ => 1)(_ + _)
Bonus: If you have cats in scope, you can just do:
items.foldMap(item => Map(item.key -> 1))
megri
@megri
@BalmungSan Thanks, but I wanted a builder version specifically. I'm just coding for fun and part of that is exploring the standard library. Not having a way to build a map stumped me and I figured I had to be missing something, but maybe it's just an omission..
I think the underlying issue is that all collection builders return a base trait Builder, which has no specific knowledge of maps for instance. So when you do Map.newBuilder[String, Int] you end up with a Builder[(String, Int), Map[String, Int]], which has no knowledge of maps specifically.
Luis Miguel Mejía Suárez
@BalmungSan
@megri Well if you add a new key-value pair whose key was already present it overwrite the previous key.
Also, under the hood a MapBuilder is just a mutable map that also has a mutable version of the method I explained above,
Anyways, Builders are intended for the stdlib itself, not really for users.
So that is why there is no specific builder for Map with the method you want.
In any case, you should not wonder for this kind of low level details.
megri
@megri

Anyways, Builders are intended for the stdlib itself, not really for users.

I find that statement questionable.

And I understand that I can overwrite an already existing key with a new one. What I'm specifically looking for is a way to do it without recomputing the whole map every time I change a key. I know I can use something like mutable.Map or java.util.Map, but I was specifically looking for something to build an immutable map, but avoiding the overhead. And before you say "the overhead might not matter", then yes, you're right, but I was looking for a way to do it none the less :)
Luis Miguel Mejía Suárez
@BalmungSan
mutable.Map.updateWith
Or again, just look for something higher level like groupMapReduce which are optimized under the hood.
Matt Hicks
@darkfrog26
Anyone needing help migrating away from log4j to Scribe, just let me know, I'd be happy to help. ;)
lambook
@lambook
i'm looking for a library to handle HEX operations (hex String to byte array etc..), i have this library org.apache.commons.codec, is there any core scala library to do the same thing?
ritschwumm
@ritschwumm
@lambook i don't think the core lib has it - but imho that's one of the things that are too simple to be worth adding a third part dependency.
lambook
@lambook

@lambook i don't think the core lib has it - but imho that's one of the things that are too simple to be worth adding a third part dependency.

is this an official library ? i m looking for a library that is widely used

johannes karoff
@cornerman
Hi, I am trying to write a macro in scala 3, where I need to list all abstract methods of a trait - so I want to ignore all implemented member methods.
I am using TypeTree.of[T].memberMethods, but do not know how to filter.