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

Allow range to return ints if all args are ints #3381

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

emlyn
Copy link
Contributor

@emlyn emlyn commented Feb 22, 2024

This change makes the range function return integers if all arguments are integers.

I don't think this should break anything, since the values returned should be unchanged,
and I think integers should be accepted anywhere floats are expected.

This would allow things like the following to work:

live_loop :foo do
  sample "drum", range(2, 6).tick
  sleep 0.5
end

Currently that fails with an error like: Unknown sample filter type: Float - got: 2.0 (RuntimeError),
which can cause confusion (see e.g. https://in-thread.sonic-pi.net/t/force-integer-from-a-range/8625/1).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant