Scala: How to return a tuple in a function? “type mismatch”Scala type inference failure on “? extends” in Java codeParametric type + function requires a string as second parameter?Type mismatch in scala while using eclipseScala - type mismatch; found Int, required StringScala Type MisMatch Error in sparkScala mapValues() type mismatchscala mismatch & inferred type arguments with JavaHow to flatten tuples in Spark?How to use Gremlin in Scala script?Strange Scala 'Type mismatch' error for tuples

MAXDOP Settings for SQL Server 2014

We have a love-hate relationship

Should I install hardwood flooring or cabinets first?

Hot bath for aluminium engine block and heads

If a character with the Alert feat rolls a crit fail on their Perception check, are they surprised?

About a little hole in Z'ha'dum

How should I respond when I lied about my education and the company finds out through background check?

Why does Async/Await work properly when the loop is inside the async function and not the other way around?

Gibbs free energy in standard state vs. equilibrium

Flux received by a negative charge

Are lightweight LN wallets vulnerable to transaction withholding?

Why do IPv6 unique local addresses have to have a /48 prefix?

What is the gram­mat­i­cal term for “‑ed” words like these?

How to align and center standalone amsmath equations?

A social experiment. What is the worst that can happen?

What (else) happened July 1st 1858 in London?

Some numbers are more equivalent than others

Engineer refusing to file/disclose patents

What linear sensor for a keyboard?

When quoting, must I also copy hyphens used to divide words that continue on the next line?

Can the Supreme Court overturn an impeachment?

Folder comparison

How can Trident be so inexpensive? Will it orbit Triton or just do a (slow) flyby?

Diode in opposite direction?



Scala: How to return a tuple in a function? “type mismatch”


Scala type inference failure on “? extends” in Java codeParametric type + function requires a string as second parameter?Type mismatch in scala while using eclipseScala - type mismatch; found Int, required StringScala Type MisMatch Error in sparkScala mapValues() type mismatchscala mismatch & inferred type arguments with JavaHow to flatten tuples in Spark?How to use Gremlin in Scala script?Strange Scala 'Type mismatch' error for tuples













1















I'm using the library gremlin-scala to interact with Janusgraph.



Using the DSL, a way to insert a new vertex is by doing the following:



val Id = Key[Long]("id")
val Name = Key[String]("name")
graph + ("label", Id -> 42, Name -> "Mike")


I want to make this part into a a function ("label", Id -> 42, Name -> "Mike")



case class VertexModel(id: Long, name: String) 
def toVertex: (Label, KeyValue[Long], KeyValue[String]) =
val Id = Key[Long]("id")
val Name = Key[String]("name")
("item", Id -> id, Name -> name)



val model = VertexModel(1, "Bill")
graph + model.toVertex


This fails with the following error:



Error:(26, 11) type mismatch;
found : T1
required: gremlin.scala.Label
(which expands to) String
graph + vertex
Error:(26, 11) type mismatch;
found : T2
required: gremlin.scala.KeyValue[Long]
graph + vertex
Error:(26, 11) type mismatch;
found : T3
required: gremlin.scala.KeyValue[String]
graph + vertex


Not sure how to fix this.










share|improve this question
























  • From gremlin-scala's source code it looks like the argument to + on a graph isn't a tuple but just a regular argument list.

    – Levi Ramsey
    Mar 21 at 14:34
















1















I'm using the library gremlin-scala to interact with Janusgraph.



Using the DSL, a way to insert a new vertex is by doing the following:



val Id = Key[Long]("id")
val Name = Key[String]("name")
graph + ("label", Id -> 42, Name -> "Mike")


I want to make this part into a a function ("label", Id -> 42, Name -> "Mike")



case class VertexModel(id: Long, name: String) 
def toVertex: (Label, KeyValue[Long], KeyValue[String]) =
val Id = Key[Long]("id")
val Name = Key[String]("name")
("item", Id -> id, Name -> name)



val model = VertexModel(1, "Bill")
graph + model.toVertex


This fails with the following error:



Error:(26, 11) type mismatch;
found : T1
required: gremlin.scala.Label
(which expands to) String
graph + vertex
Error:(26, 11) type mismatch;
found : T2
required: gremlin.scala.KeyValue[Long]
graph + vertex
Error:(26, 11) type mismatch;
found : T3
required: gremlin.scala.KeyValue[String]
graph + vertex


Not sure how to fix this.










share|improve this question
























  • From gremlin-scala's source code it looks like the argument to + on a graph isn't a tuple but just a regular argument list.

    – Levi Ramsey
    Mar 21 at 14:34














1












1








1








I'm using the library gremlin-scala to interact with Janusgraph.



Using the DSL, a way to insert a new vertex is by doing the following:



val Id = Key[Long]("id")
val Name = Key[String]("name")
graph + ("label", Id -> 42, Name -> "Mike")


I want to make this part into a a function ("label", Id -> 42, Name -> "Mike")



case class VertexModel(id: Long, name: String) 
def toVertex: (Label, KeyValue[Long], KeyValue[String]) =
val Id = Key[Long]("id")
val Name = Key[String]("name")
("item", Id -> id, Name -> name)



val model = VertexModel(1, "Bill")
graph + model.toVertex


This fails with the following error:



Error:(26, 11) type mismatch;
found : T1
required: gremlin.scala.Label
(which expands to) String
graph + vertex
Error:(26, 11) type mismatch;
found : T2
required: gremlin.scala.KeyValue[Long]
graph + vertex
Error:(26, 11) type mismatch;
found : T3
required: gremlin.scala.KeyValue[String]
graph + vertex


Not sure how to fix this.










share|improve this question
















I'm using the library gremlin-scala to interact with Janusgraph.



Using the DSL, a way to insert a new vertex is by doing the following:



val Id = Key[Long]("id")
val Name = Key[String]("name")
graph + ("label", Id -> 42, Name -> "Mike")


I want to make this part into a a function ("label", Id -> 42, Name -> "Mike")



case class VertexModel(id: Long, name: String) 
def toVertex: (Label, KeyValue[Long], KeyValue[String]) =
val Id = Key[Long]("id")
val Name = Key[String]("name")
("item", Id -> id, Name -> name)



val model = VertexModel(1, "Bill")
graph + model.toVertex


This fails with the following error:



Error:(26, 11) type mismatch;
found : T1
required: gremlin.scala.Label
(which expands to) String
graph + vertex
Error:(26, 11) type mismatch;
found : T2
required: gremlin.scala.KeyValue[Long]
graph + vertex
Error:(26, 11) type mismatch;
found : T3
required: gremlin.scala.KeyValue[String]
graph + vertex


Not sure how to fix this.







scala gremlin-scala






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 21 at 13:57







drum

















asked Mar 21 at 13:49









drumdrum

1,78943654




1,78943654












  • From gremlin-scala's source code it looks like the argument to + on a graph isn't a tuple but just a regular argument list.

    – Levi Ramsey
    Mar 21 at 14:34


















  • From gremlin-scala's source code it looks like the argument to + on a graph isn't a tuple but just a regular argument list.

    – Levi Ramsey
    Mar 21 at 14:34

















From gremlin-scala's source code it looks like the argument to + on a graph isn't a tuple but just a regular argument list.

– Levi Ramsey
Mar 21 at 14:34






From gremlin-scala's source code it looks like the argument to + on a graph isn't a tuple but just a regular argument list.

– Levi Ramsey
Mar 21 at 14:34













1 Answer
1






active

oldest

votes


















2














Why do you need extension method toVertex?



Doesn't this work just like



import gremlin.scala._
import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph

object App

implicit val graph: ScalaGraph = TinkerGraph.open.asScala

case class VertexModel(id: Long, name: String)

val model = VertexModel(1, "Bill")
graph + model



?



build.sbt



scalaVersion := "2.12.8"
libraryDependencies += "com.michaelpollmeier" %% "gremlin-scala" % "3.4.0.4"
libraryDependencies += "org.apache.tinkerpop" % "tinkergraph-gremlin" % "3.4.0"





share|improve this answer

























  • That's cool! Didn't know that was possible. 1 more question: How can I add the label to the class? Expanding on your solution: case class VertexModel(label: Label, id: Long, name: String), I get Name cannot be in protected namespace: label

    – drum
    Mar 21 at 14:49











  • Sorry, can't reproduce. case class VertexModel(label: Label, id: Long, name: String) val model = VertexModel("item", 1, "Bill") graph + model compiles for me.

    – Dmytro Mitin
    Mar 21 at 14:56












  • That's during runtime by the gremlin server

    – drum
    Mar 21 at 15:12











  • Another issue is that I cannot use different Key names. For example I want a key type but I can't do case class VertexModel(type: String, id: Long, name: String) because type is a keyword.

    – drum
    Mar 21 at 15:20






  • 1





    What if you try label, type in backticks?

    – Dmytro Mitin
    Mar 21 at 15:35










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55281951%2fscala-how-to-return-a-tuple-in-a-function-type-mismatch%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









2














Why do you need extension method toVertex?



Doesn't this work just like



import gremlin.scala._
import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph

object App

implicit val graph: ScalaGraph = TinkerGraph.open.asScala

case class VertexModel(id: Long, name: String)

val model = VertexModel(1, "Bill")
graph + model



?



build.sbt



scalaVersion := "2.12.8"
libraryDependencies += "com.michaelpollmeier" %% "gremlin-scala" % "3.4.0.4"
libraryDependencies += "org.apache.tinkerpop" % "tinkergraph-gremlin" % "3.4.0"





share|improve this answer

























  • That's cool! Didn't know that was possible. 1 more question: How can I add the label to the class? Expanding on your solution: case class VertexModel(label: Label, id: Long, name: String), I get Name cannot be in protected namespace: label

    – drum
    Mar 21 at 14:49











  • Sorry, can't reproduce. case class VertexModel(label: Label, id: Long, name: String) val model = VertexModel("item", 1, "Bill") graph + model compiles for me.

    – Dmytro Mitin
    Mar 21 at 14:56












  • That's during runtime by the gremlin server

    – drum
    Mar 21 at 15:12











  • Another issue is that I cannot use different Key names. For example I want a key type but I can't do case class VertexModel(type: String, id: Long, name: String) because type is a keyword.

    – drum
    Mar 21 at 15:20






  • 1





    What if you try label, type in backticks?

    – Dmytro Mitin
    Mar 21 at 15:35















2














Why do you need extension method toVertex?



Doesn't this work just like



import gremlin.scala._
import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph

object App

implicit val graph: ScalaGraph = TinkerGraph.open.asScala

case class VertexModel(id: Long, name: String)

val model = VertexModel(1, "Bill")
graph + model



?



build.sbt



scalaVersion := "2.12.8"
libraryDependencies += "com.michaelpollmeier" %% "gremlin-scala" % "3.4.0.4"
libraryDependencies += "org.apache.tinkerpop" % "tinkergraph-gremlin" % "3.4.0"





share|improve this answer

























  • That's cool! Didn't know that was possible. 1 more question: How can I add the label to the class? Expanding on your solution: case class VertexModel(label: Label, id: Long, name: String), I get Name cannot be in protected namespace: label

    – drum
    Mar 21 at 14:49











  • Sorry, can't reproduce. case class VertexModel(label: Label, id: Long, name: String) val model = VertexModel("item", 1, "Bill") graph + model compiles for me.

    – Dmytro Mitin
    Mar 21 at 14:56












  • That's during runtime by the gremlin server

    – drum
    Mar 21 at 15:12











  • Another issue is that I cannot use different Key names. For example I want a key type but I can't do case class VertexModel(type: String, id: Long, name: String) because type is a keyword.

    – drum
    Mar 21 at 15:20






  • 1





    What if you try label, type in backticks?

    – Dmytro Mitin
    Mar 21 at 15:35













2












2








2







Why do you need extension method toVertex?



Doesn't this work just like



import gremlin.scala._
import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph

object App

implicit val graph: ScalaGraph = TinkerGraph.open.asScala

case class VertexModel(id: Long, name: String)

val model = VertexModel(1, "Bill")
graph + model



?



build.sbt



scalaVersion := "2.12.8"
libraryDependencies += "com.michaelpollmeier" %% "gremlin-scala" % "3.4.0.4"
libraryDependencies += "org.apache.tinkerpop" % "tinkergraph-gremlin" % "3.4.0"





share|improve this answer















Why do you need extension method toVertex?



Doesn't this work just like



import gremlin.scala._
import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph

object App

implicit val graph: ScalaGraph = TinkerGraph.open.asScala

case class VertexModel(id: Long, name: String)

val model = VertexModel(1, "Bill")
graph + model



?



build.sbt



scalaVersion := "2.12.8"
libraryDependencies += "com.michaelpollmeier" %% "gremlin-scala" % "3.4.0.4"
libraryDependencies += "org.apache.tinkerpop" % "tinkergraph-gremlin" % "3.4.0"






share|improve this answer














share|improve this answer



share|improve this answer








edited 2 days ago

























answered Mar 21 at 14:39









Dmytro MitinDmytro Mitin

7,947619




7,947619












  • That's cool! Didn't know that was possible. 1 more question: How can I add the label to the class? Expanding on your solution: case class VertexModel(label: Label, id: Long, name: String), I get Name cannot be in protected namespace: label

    – drum
    Mar 21 at 14:49











  • Sorry, can't reproduce. case class VertexModel(label: Label, id: Long, name: String) val model = VertexModel("item", 1, "Bill") graph + model compiles for me.

    – Dmytro Mitin
    Mar 21 at 14:56












  • That's during runtime by the gremlin server

    – drum
    Mar 21 at 15:12











  • Another issue is that I cannot use different Key names. For example I want a key type but I can't do case class VertexModel(type: String, id: Long, name: String) because type is a keyword.

    – drum
    Mar 21 at 15:20






  • 1





    What if you try label, type in backticks?

    – Dmytro Mitin
    Mar 21 at 15:35

















  • That's cool! Didn't know that was possible. 1 more question: How can I add the label to the class? Expanding on your solution: case class VertexModel(label: Label, id: Long, name: String), I get Name cannot be in protected namespace: label

    – drum
    Mar 21 at 14:49











  • Sorry, can't reproduce. case class VertexModel(label: Label, id: Long, name: String) val model = VertexModel("item", 1, "Bill") graph + model compiles for me.

    – Dmytro Mitin
    Mar 21 at 14:56












  • That's during runtime by the gremlin server

    – drum
    Mar 21 at 15:12











  • Another issue is that I cannot use different Key names. For example I want a key type but I can't do case class VertexModel(type: String, id: Long, name: String) because type is a keyword.

    – drum
    Mar 21 at 15:20






  • 1





    What if you try label, type in backticks?

    – Dmytro Mitin
    Mar 21 at 15:35
















That's cool! Didn't know that was possible. 1 more question: How can I add the label to the class? Expanding on your solution: case class VertexModel(label: Label, id: Long, name: String), I get Name cannot be in protected namespace: label

– drum
Mar 21 at 14:49





That's cool! Didn't know that was possible. 1 more question: How can I add the label to the class? Expanding on your solution: case class VertexModel(label: Label, id: Long, name: String), I get Name cannot be in protected namespace: label

– drum
Mar 21 at 14:49













Sorry, can't reproduce. case class VertexModel(label: Label, id: Long, name: String) val model = VertexModel("item", 1, "Bill") graph + model compiles for me.

– Dmytro Mitin
Mar 21 at 14:56






Sorry, can't reproduce. case class VertexModel(label: Label, id: Long, name: String) val model = VertexModel("item", 1, "Bill") graph + model compiles for me.

– Dmytro Mitin
Mar 21 at 14:56














That's during runtime by the gremlin server

– drum
Mar 21 at 15:12





That's during runtime by the gremlin server

– drum
Mar 21 at 15:12













Another issue is that I cannot use different Key names. For example I want a key type but I can't do case class VertexModel(type: String, id: Long, name: String) because type is a keyword.

– drum
Mar 21 at 15:20





Another issue is that I cannot use different Key names. For example I want a key type but I can't do case class VertexModel(type: String, id: Long, name: String) because type is a keyword.

– drum
Mar 21 at 15:20




1




1





What if you try label, type in backticks?

– Dmytro Mitin
Mar 21 at 15:35





What if you try label, type in backticks?

– Dmytro Mitin
Mar 21 at 15:35



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55281951%2fscala-how-to-return-a-tuple-in-a-function-type-mismatch%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript