endformationage has quit [Ping timeout: 240 seconds]
endforma1 has quit [Ping timeout: 264 seconds]
endforma1 has joined #ponylang
svenskunganka has joined #ponylang
<svenskunganka>
Hi! I've decided to try to learn pony, and started reading the tutorial for three hours ago or so. My project for learning new languages is always to build a filetype matching library that matches by magic numbers. However I'm not sure what the pony way is to do multiple expressions in a single if. This is what I got so far: https://playground.ponylang.org/?gist=88314b25eb154bcf45b7240e39abf5d5
<svenskunganka>
I want to check an arbitrary-sized Array[U8] at specific indices for a value
khan has joined #ponylang
khan_ has joined #ponylang
khan has quit [Ping timeout: 256 seconds]
khan_ is now known as khan
<vaninwagen>
Looks good, you can combine multiple if conditions with and and or
<vaninwagen>
For your use case it might be interesting to use buffered.Reader to read your magic Numbers as integer values from a byte array https://stdlib.ponylang.org/buffered-Reader/
khan has quit [Quit: khan]
khan has joined #ponylang
khan_ has joined #ponylang
<svenskunganka>
That looks more like what I need. I understand that I can have multiple conditions inside an if, but the precedence thing would make the code quite unreadable.
<vaninwagen>
You can wrap the condition over multiple lines, if that helps
<vaninwagen>
The precedence thing might seem strange at first but it saved my ass more than once already
khan has quit [Ping timeout: 264 seconds]
khan_ is now known as khan
<svenskunganka>
How'd that look like? I tried breaking it into multiple lines but I got the "syntax error: unterminated if expression"
<svenskunganka>
brb, gonna buy some breakfast
<vaninwagen>
You need to put the single comparisons in parens, otherwise they might be mixed up with the and operators. Also dont forget the 'then' at the end of your if condition.
<vaninwagen>
I am at the phone right now, and the playground is pretty much unusable here, i will post an example later