## Where communities thrive

• Join over 1.5M+ people
• Join over 100K+ communities
• Free without limits
• Create your own community
##### Activity
• 12:35
SethTisue commented #9635
• 12:34
lrytz commented #6944
• 12:33
SethTisue commented #9635
• 12:33
lrytz reopened #6944
• 12:33
lrytz commented #6944
• 12:27
SethTisue commented #2025
• 12:24
SethTisue labeled #9636
• 12:18
neko-kai commented #12398
• 12:17
neko-kai commented #12398
• 12:16
vincenzobaz synchronize #2005
• 12:15
neko-kai commented #12398
• 12:13

dwijnand on 2.13.x

Restarr on 2.13.6 Merge pull request #9636 from lā¦ (compare)

• 12:13
dwijnand closed #9636
• 12:12
dwijnand commented #12398
• 12:09
neko-kai commented #12398
• 12:03
vincenzobaz synchronize #2005
• 11:54
neko-kai commented #2015
• 11:53
dwijnand commented #12398
• 11:53
dwijnand labeled #12398
• 11:53
dwijnand labeled #12398
Hanns Holger Rutz
@Sciss
@SystemFw thanks for the explanation, good to know it works without macros
Rob Norris
@tpolecat
@ def notInt[A](a: A)(implicit ev: A =:!= Int): A = a
defined function notInt

@ notInt("foo")
res3: String = "foo"

@ notInt(3)
cmd4.sc:1: ambiguous implicit values:
both method neqAmbig1 in package shapeless of type [A]=> A =:!= A
and method neqAmbig2 in package shapeless of type [A]=> A =:!= A
match expected type Int =:!= Int
val res4 = notInt(3)
^
Compilation Failed

@ def foo[A](a: A): A = notInt(a)
defined function foo

@ foo(1)
res5: Int = 1
It's really easy to defeat the type inequality constraint. Just FYI.
Hanns Holger Rutz
@Sciss
!
Jon Pretty
@propensive

@saifjsl I think @propensive still has Scala 2.6 in production somewhere. People are reluctant to destabilize codebases just for the sake of keeping up to date.

Confirmed. I have a Scala 2.6.1 web application which runs for about a month each year. My client keeps paying me more each year to keep it running. My biggest concern isn't so much the Scala 2.6.1 compiler but the shoddy coding practices I used extensively in about 2007.

Dale Wijnand
@dwijnand
It would be interesting to see that code. Maybe you can anonymise it and open-source it, somehow?
Otto Chrons
@ochrons
I cannot make it to Scala World this year, so my early bird ticket is FOR SALE. Conference ticket + Functional Frenzy workshops, 395ā¬ (VAT 0%). Conference info https://scala.world/ (it's by far the best Scala conference in rural England! :stuck_out_tongue_winking_eye: )
Oscar Vargas Torres
@oscarvarto
Hi! Is there a simple way to make scalac report a warning for methods that are undefined (using ???)?
For example, in the following snippet:
def bar(x: Int): Int = ???
Martijn Hoekstra
@martijnhoekstra
Not that I know of. A workaround could be having something like @deprecated("Undefined method") def ????: Nothing = ??? and they'll show up in your deprecation warnings
it's a good idea to have an option to warn on ??? in the compiler IMO
even though generally I don't think building knowledge of the stdlib into the compiler is usually a good idea
it sounds like a fun project tbh
Josef
@Josef-Vonasek

Any idea how to resolve this type inference bug? :

def foo[T, X <: XX[T]](x: X): X = macro fooMacro[T, X]

def fooMacro[T, X<: XX[T]](c: Context)(x: c.Expr[X]): c.Expr[X] = ...

Error:(9, 11) macro implementation has incompatible shape: ...
type arguments [Nothing,X] do not conform to method fooMacro type parameter bounds [T,X<: XX[T]]>

Oscar Vargas Torres
@oscarvarto
@martijnhoekstra Thanks for replying! I once spent some time chasing for a bug caused by an unimplemented method (I forgot to implement that method)
Deepak Singh
@dpk3d
Guys Can someone help me converting Seconds = 7500s into 2h5m0s..?
Deepak Singh
@dpk3d

def solution(n: Int): String = {
// write your code in Scala 2.12
var s = n % (24 * 3600)

val m = (n / 60 ) % 60

val h = (n / 60 / 60 ) % 24

s = s % 60

val strin = "%2dh%2dm%2ds".format(h, m, s).stripMargin

return strin

this solution is giving me space I need in hhmmss
Otto Chrons
@ochrons
replace %2d with %d
also var s = n % (24 * 3600) is unnecessary, simple val s = n % 60 works
Deepak Singh
@dpk3d
@ochrons got 2h 5m0s but my expected is 2h5m0s
Deepak Singh
@dpk3d

I have a string S = "00-44 48 555 8361"

And I want to format the string that digits are grouped in blocks of length three separated by - dash . Final block can be two digits.

Expectation is "004-448-555-583-61"

Can someone gives me heads up on this

Josef
@Josef-Vonasek
in pseudocode: S.filter(!_.inside("- ")).groupBy3.mkString("-")
Deepak Singh
@dpk3d

I've done in Python
Can someone convert in Scala

Solution

ph = "00-44 48 5555 8361"

def normalize(ph):
tmp = []
final_str = ""
index = 0
while( index < len(ph)):
if ph[index] == ' ' or ph[index] == '-':
index +=1
continue
tmp.append(ph[index])
if len(tmp) == 3:
str = ""
final_str = final_str + '-' +str.join(tmp)
tmp = []
index+=1
str = ""
final_str = final_str + '-' +str.join(tmp)
final_str = final_str.lstrip("-").rstrip("-")
return final_str

print (ph)
print (normalize(ph))

Andriy Plokhotnyuk
@plokhotnyuk
s.filter(_.isDigit).sliding(3, 3).mkString("-")
Josef
@Josef-Vonasek
^ or this :D
Did not know about sliding, nice.
Deepak Singh
@dpk3d
@Josef-Vonasek @plokhotnyuk do I've to import something
Andriy Plokhotnyuk
@plokhotnyuk
no
Josef
@Josef-Vonasek
use @plokhotnyuk code, mine is just pseudocode, some of the functions do not exist
Andriy Plokhotnyuk
@plokhotnyuk
here is how it looks in Scala REPL:
$scala Welcome to Scala 2.13.0 (OpenJDK 64-Bit GraalVM CE 19.1.1, Java 1.8.0_222). Type in expressions for evaluation. Or try :help. scala> val s = "00-44 48 555 8361" s: String = 00-44 48 555 8361 scala> s.filter(_.isDigit).sliding(3, 3).mkString("-") ^ warning: method sliding in class StringOps is deprecated (since 2.13.0): Use s.toSeq.sliding(...).map(_.unwrap) instead of s.sliding(...) res0: String = 004-448-555-836-1 ! "00-44 48 555 8361".filter(_.isDigit).sliding(3, 3).mkString("-") multibot1 @multibot1 ^ warning: method sliding in class StringOps is deprecated (since 2.13.0): Use 's.toSeq.sliding(...).map(_.unwrap)' instead of 's.sliding(...)' String = 004-448-555-836-1 Andriy Plokhotnyuk @plokhotnyuk multibot use Scala 2.13 too :) Josef @Josef-Vonasek ! 1 + 1 multibot1 @multibot1 Int = 2 Deepak Singh @dpk3d I've little change in case suppose input is "004-44 8553 615 4" -->. Final block or last two block can be of length two ā¦ output "004-448 -553 -61-54" @plokhotnyuk thanks can you give heads up for above case also Deepak Singh @dpk3d Can someone provide the solution for below Problem in Scala:: It's in python I want in scala https://stackoverflow.com/questions/47448218/find-the-sentence-containing-the-largest-number-of-words-in-a-given-text-codilit Daniel Gordon @DanielGGordon I have this regex with matching groups, and l tested it online via some free regex tester, but in Scala I am having strange results.  val ProductExtractorRegex: Regex = { val Product = """.+?""" //name of the product val Dvn = """[A-Z0-9]{5}""" val Region = """[A-Z]{2,}""" val ProductCode = """[A-Z0-9]{5}""" val ProductSubtype = """[A-Z0-9]{5}""" val Extension = """(zip|z[0-9]{2})""" s"($Product)[\\-_]($Dvn)[\\-_]($Region)[\\-_]($ProductCode)[\\-_]($ProductSubtype)\\.(\$Extension)".r
}

val ProductExtractorRegex(productName, dvn, region, productCode, productSubtypeWithUnderscore, extension) = "SOMEPRODUCT_12345_SOMEREGION_OLELS_SLSLS.z01"

I get a scala.match error on this, and it is because of the ProductSubtype. If I get rid of it, and remove that part from the string - it works. But after I add the ProductSubtype, the match fails. Even though it is a very simple 5x letter string.

Martijn Hoekstra
@martijnhoekstra
nothing strikes me as odd -- do you have test input for it?
Daniel Gordon
@DanielGGordon
"SOMEPRODUCT_12345_SOMEREGION_OLELS_SLSLS.z01" is the test input I'm testing right now
Martijn Hoekstra
@martijnhoekstra
Deepak Singh
@dpk3d
@martijnhoekstra š¤š»š
Daniel Gordon
@DanielGGordon
@martijnhoekstra that ProductSubtype was actually supposed to be an optional group, but that didn't work either. Even as non-optional capture group, I get the match error
Martijn Hoekstra
@martijnhoekstra
Extension is two groups
or rather, (Extension) is two groups
Daniel Gordon
@DanielGGordon
it is?
Martijn Hoekstra
@martijnhoekstra
Either remove the parents around Extension, or around its interpolation