Closed craftgear closed 6 years ago
Great stuff.
Since we're using JavaScript notation, would it make sense to do Data.items.length?
On 4 Mar 2016, at 05:19, Shunsuke Watanabe notifications@github.com wrote:
Add a new format to count elements in a response slice.
This would be useful when you expect an exact amount of data to retrieve.
Usage:
Get /foo/total
Get 10 items
len(Data): 10 You can view, comment on, or merge this pull request online at:
https://github.com/matryer/silk/pull/29
Commit Summary
add a format 'len(Data): int' to count elements in a slice File Changes
M runner/run.go (12) Patch Links:
https://github.com/matryer/silk/pull/29.patch https://github.com/matryer/silk/pull/29.diff — Reply to this email directly or view it on GitHub.
That makes sense.
Then how about making it as Data.length
?
When you get response as an array response.length
is intuitive IMHO, moreover it's shorter.
Wait, length
should work with properties and strings.
Let me think about this again.
Is this ready to go now?
Not yet. Give me a little more time.
Maybe Data.length(): 6
would avoid the collision with a length
attribute?
Maybe it’s not a collision… you might well want to assert the length of a string?
On 11 Mar 2016, at 15:14, David Larlet notifications@github.com wrote:
Maybe Data.length(): 6 would avoid the collision with a length attribute?
— Reply to this email directly or view it on GitHub https://github.com/matryer/silk/pull/29#issuecomment-195598060.
@matryer Yes, I try to check String.length
.
Do you think it's unnecessary?
I'd love to get this done and into the next pre-release if possible. @craftgear can you have a look at my comments please?
Add a new format to count elements in a response slice.
This would be useful when you expect an exact amount of data to retrieve.
Usage: