FAQ
I agree, it makes it much nicer to read it that way.

passing a point to Result is a good call btw, I like the syntax that way
more:
results := []T; err :=
linq.From(...).Where(...).Select(...).Result(&results)

~
Doug.
On Saturday, May 18, 2013 9:37:34 AM UTC+8, soapboxcicero wrote:

You can reflect on the func's you're being passed and use reflection
to make sure the types in the signature match and call the func with
appropriately created reflect.Values. It makes the implementation more
complex but it means you'd be able to do write that as:

results := linq.From(set).Where(func(x *T) bool {
return x.Value > 10 && x.Value2 == "Hello World"
}).Select(func(x *T) ResultType {
return ResultType {
v1 : x.Value3,
v2 : x.Value4,
}
}).DistinctOnKey("Value2").
Results()

The only type assertion would be after the call to Results, and you
could eliminate that by passing a pointer of whatever to Results and
setting its value with reflect.

Not much safer or any easier to do (in fact, harder to do, I'd
imagine) but it wouldn't look as interface{}-y or as type assert-y
when you're actually using the library.
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 4 of 18 | next ›
Discussion Overview
groupgolang-nuts @
categoriesgo
postedMay 18, '13 at 1:04a
activeMay 18, '13 at 8:27p
posts18
users7
websitegolang.org

People

Translate

site design / logo © 2021 Grokbase