pebble icon indicating copy to clipboard operation
pebble copied to clipboard

Cannot use methods that take int

Open ogrammer opened this issue 5 years ago • 5 comments

{{ arraylist.get(0) }} does not work because numbers seem to be long by default in pebble and that method takes int.

ogrammer avatar Dec 15 '20 22:12 ogrammer

This is a very serious issue as there is no possibility to cast or define variable type in pebble

ogrammer avatar Dec 31 '20 12:12 ogrammer

Why are numbers long by default though, there would be next to no problem if default was int and 123L was long like in Java

ogrammer avatar Dec 31 '20 12:12 ogrammer

In PebbleEngine Builder, you can set literalDecimalTreatedAsInteger to true if you want that behavior

ebussieres avatar Jan 01 '21 19:01 ebussieres

@ebussieres Thanks, but how do I use longs if I do that? I need to kill support for one to use the other, does not seem very clean to me but I have no methods that take long so it's no problem. (On that note, using other data types smaller than int probably doesn't work either as the concept of casts does not exist.)

Shouldn't the default (unconfigured) be int? What's the reason for having long by default?

ogrammer avatar Jan 10 '21 11:01 ogrammer

If the reason for using long by default is to support larger numbers then that does not make sense because the Java default is not so and to support larger numbers one would use BigInteger/BigDecimal.

ogrammer avatar Feb 08 '21 21:02 ogrammer