On Wednesday, 1 October 2014 21:34:09 UTC+3, Guillermo Estrada wrote:
Factories sounds nice!! Kinda like working in Ruby. Do you have any
example of this ? (ir any project in github using them) to give me am idea
of am idiomatic way to refactor this.

He just means a function that returns a function... e.g.

func ByName(name string) func(*Thing) bool {
     return func(t *Thing) { return t.Name == name }

Also, you might be overthinking this..
for loops are simpler solution in these cases... e.g.

for _, t := range things {
    if t.Name == "something" && t.Age > 10 {

+ egon

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/d/optout.

Search Discussions

Discussion Posts


Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 6 of 11 | next ›
Discussion Overview
groupgolang-nuts @
postedSep 30, '14 at 3:11a
activeOct 4, '14 at 5:16a



site design / logo © 2021 Grokbase