You mean that conditionals are not logic?
</rhetorical question>
--
Gustavo Niemeyer
http://niemeyer.net
http://niemeyer.net/plus
http://niemeyer.net/twitter
http://niemeyer.net/blog
-- I'm not absolutely sure of anything.
Value "existence" is actually a comparison. Anyone that argues that
logic isn't necessary in templates either has never used templates or
doesn't know what logic is. That said, I certainly agree that people
often put *too much* logic in the template, which is a more subtle
issue.
On Mon, Apr 2, 2012 at 19:32, Kyle Lemons <kev...@google.com> wrote:
> I think logic is fine in templates (especially conditionals and looping),
> but "computation", "manipulation" and "processing" are a bit beyond the
The fact you've quoted every word there means you probably understand
you're in shaky ground. I'd prefer not to get into that argument,
though.
My apologies. It certainly wasn't my intention to be rude, although
you're probably right.
(...)
> Anyway, if you want to learn about logic-less templates just google it (for
> sure you need to) otherwise stop trolling.
I wasn't trolling. I was providing some insight. I'll shut up now, though.
// eq reports whether the first argument is equal to
// any of the remaining arguments.
func eq(args ...interface{}) bool {
if len(args) == 0 {
return false
}
x := args[0]
switch x := x.(type) {
case string, int, int64, byte, float32, float64:
for _, y := range args[1:] {
if x == y {
return true
}
}
return false
}
for _, y := range args[1:] {
if reflect.DeepEqual(x, y) {
return true
}
}
return false
}
Russ
By the way, there could be more types on that case; if you borrow this
function, be sure to add the types you need.
-rob
Wouldn't it be equivalent to just having "switch x.(type) {", in this
case, since x was actually already of interface type? I guess you're
looking at it from the perspective of a language without such an
interface type, in which this would be pretty inconvenient to do?
-rob
Russ