Predef.$eq$colon$eq<A,B>

241 views
Skip to first unread message

dali.mi...@gmail.com

unread,
Mar 8, 2017, 7:39:19 PM3/8/17
to scala-user
Hi,
I want to use a scala method with java. I need to pass Predef.$eq$colon$eq<A,B> argument. But I did not find any example to write Predef.$eq$colon$eq in java.
Can you help me please

Bartek Hamielec

unread,
Mar 9, 2017, 11:30:19 AM3/9/17
to scala-user
Could you please provide more details? :)

Regards,
Bartek

Oliver Ruebenacker

unread,
Mar 9, 2017, 12:36:00 PM3/9/17
to Bartek Hamielec, scala-user

     Hello,

  I think you cannot refer to it directly in Java, but you can write an adapter in Scala, like

object PredefAdapter {
  val eqColonEq = Predef.=:=
}

  and then refer to it in Java as PredefAdapter.eqColonEq.

     Best, Oliver

--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-user+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Oliver Ruebenacker
Senior Software Engineer, Diabetes Portal, Broad Institute

dali.mi...@gmail.com

unread,
Mar 9, 2017, 1:29:57 PM3/9/17
to scala-user
Hi,
I am using Graphx with java. I want to use the Graph.mapVertices() method and I need to pass Predef.$eq$colon$eq<VD,VD2> argument.

Stephen Compall

unread,
Mar 9, 2017, 7:27:36 PM3/9/17
to scala...@googlegroups.com

On 3/9/17 1:29 PM, dali.mi...@gmail.com wrote:

I am using Graphx with java. I want to use the Graph.mapVertices() method and I need to pass Predef.$eq$colon$eq<VD,VD2> argument.

Sure.

class Leibniz {
  static <T> scala.Predef.$eq$colon$eq<T, T> reflexivity() {
    return scala.Predef.$eq$colon$eq$.MODULE$.tpEquals();
  }
}


--
Stephen Compall

dali.mi...@gmail.com

unread,
Mar 10, 2017, 4:07:19 AM3/10/17
to scala-user
Thank you,
I created a class Predef1:
public class Predef1 {
 static public <T> scala.Predef.$eq$colon$eq<T, T> reflexivity() {
   return scala.Predef.$eq$colon$eq$.MODULE$.tpEquals();
 }
}
and I use Predef1.reflexivity() to pass th argument but I have this error:
The method mapVertices(..., Predef.$eq$colon$eq<String,VD2>) is not applicable for the argument (..., Predef.$eq$colon$eq<Object,Object>)
I need to pass an argument Predef.$eq$colon$eq<String,VD2>

Jasper-M

unread,
Mar 10, 2017, 6:50:58 AM3/10/17
to scala-user
I assume VD2 is a type variable?

Then you have to do either of these:

1) Pass the reference around:

public <VD1> void myGenericMethod(VD1 vd, $eq$colon$eq<String,VD1> ev) {
  mapVertices(..., ev);
}

public void myMethod() {
  String vd = "VD";
  myGenericMethod(vd, Predef1.reflexivity());
}

2) Cast the reference:

public <VD1> void myMethod() {
  Object obj = Predef1.reflexivity();
  scala.Predef.$eq$colon$eq<String,VD1> ev = (scala.Predef.$eq$colon$eq<String,VD1>) obj;
  mapVertices(..., ev);
}

Op vrijdag 10 maart 2017 10:07:19 UTC+1 schreef dali.mi...@gmail.com:

Jasper-M

unread,
Mar 10, 2017, 6:54:09 AM3/10/17
to scala-user
s/VD1/VD2/g of course.

Op vrijdag 10 maart 2017 12:50:58 UTC+1 schreef Jasper-M:
Reply all
Reply to author
Forward
0 new messages