Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to do arithmetic #492

Closed
thedamnedrhino opened this issue Aug 22, 2016 · 2 comments
Closed

How to do arithmetic #492

thedamnedrhino opened this issue Aug 22, 2016 · 2 comments
Labels

Comments

@thedamnedrhino
Copy link

I'm trying to do some basic arithmetic, using things like <current() * 10>, but I only get 0 as result. Actually 0 is what's saved in the database so that might return null. So how is it possible to do basic arithmetic Operations in the Fixtures?

@theofidry
Copy link
Member

<something()> is the notation for calling the function something, so <current() * 10> will not work and should even throw an error IMO. I am not sure why this is not the case in 2.x but it will throw an error for sure in 3.x.

To achieve what you want to do, you need to have a custom function to do the operations. It is a bit inconvenient and might be something to enhance in the future.

@theofidry
Copy link
Member

Update on the issue, this is easily doable by using the identity function: <(10 * 5)>. The only limitations are that the identity function only knows about references and variables: <(@user->favoriteNumber * $current)> (the <current()> is accessible via the $current variable).

karser added a commit to karser/alice that referenced this issue Nov 11, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants