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
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.
ritschwumm
@ritschwumm
@lambook no, not at all. it's my personal collection of useful things. it's not even published to a public maven repo.
Hanns Holger Rutz
@Sciss

If I have

def augmentString (x: String) : Any = ()

can I disable the compiler warning:

parameter value x in method augmentString is never used

by annotating this method somehow?

Luis Miguel Mejía Suárez
@BalmungSan
@Sciss AFAIK you can do: def augmentString (@unused x: String) : Any = ()
Hanns Holger Rutz
@Sciss
@BalmungSan thanks, excellent
Luis Miguel Mejía Suárez
@BalmungSan
Did that worked?
Hanns Holger Rutz
@Sciss
yes
Hanns Holger Rutz
@Sciss
errrr, @unused doesn't cross compile in Scala 2.12. But it's part of scala-collection-compat.
Luis Miguel Mejía Suárez
@BalmungSan
:sweat_smile:
Mark T. Kennedy
@mtk
anyone else having problems reaching docs.scala-lang.org? it's mapped to icvm0053.epfl.ch (128.178.218.78) and traceroute dies at the first epfl.ch host it reaches.
Luis Miguel Mejía Suárez
@BalmungSan
Mark T. Kennedy
@mtk
thanks!
go through with this and make it runnable
johannes karoff
@cornerman
To answer my own question about finding out which member method are abstract (not implemented) in a macro, you can use: TypeTree.of[T].memberMethods.filter(_.flags.is(Flags.Deferred))
Edrick de Guzman
@edrick.deguzman_gitlab
Hello everyone, I would like to ask for some guidance/insight regarding create a jar file/package for my scala test project? I currently don't have a main class since we use test instead of main. Can anyone point me to the right direction?
Luis Miguel Mejía Suárez
@BalmungSan
@edrick.deguzman_gitlab care to elaborate?