Created
April 28, 2014 21:03
-
-
Save jnd71/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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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