Skip to content

Instantly share code, notes, and snippets.

@penland365
Created April 28, 2014 21:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save penland365/11383909 to your computer and use it in GitHub Desktop.
Save penland365/11383909 to your computer and use it in GitHub Desktop.
While I understand the benefits of creating the named portions of a Tuple via OpenStruct, It's 5 lines to create versus one, and in most cases the extra information created by using named parameters isn't beneficial, since I'm wanting to use the Tuple as a dumb ( simple) data container.
// what I'm forced to do?
def make_triforce
// blah blah business logic
struct = new OpenStruct
struct.name = //whatever
struct.age = //whatever
struct.location = //whatever
struct
end
def primary_ops
// blah blah blah
struct = make_triforce
complex_object = new ComplexObject(
somethingelse
struct.name
snakes
triforce.age
trifoce.location
)
end
// what I'd like to do
def primaryOperation(): Unit = {
// blah
// blah
val triforce = makeTriforce
val complexObject = new ComplexObject(
firstParam = somethingelse
secondParam = triforce._1
thirdParm = snakes
fourthParam = triforce._2
fifthParam = trifoce._3
)
}
def makeTriforce(): Tuple3[String, String, String] = {
// all sorts of business logic
(result1, result2, result3) / Tuple3
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment