Embed Notice
HTML Code
Corresponding Notice
- Embed this notice@hazlin
> Ruby doesn't seem to have a keyword to stick all the new stuff into its own name space.
*Usually* it is considered a sign of bad library design for the top-level namespace to get mangled like that. In this case, since it's effectively a graphics library DSL that wraps SDL2, it makes sense.
> So I am going to set that aside for now, and actually get some stuff painted to the screen...
It's actually a fun library, it's on my list, I wanted to play with animations for a generative art thing and it handles a lot of stuff that is fun to implement but is less fun to implement if you want to be working on something else.
> Though I did wonder if the * in your version had special meaning
Argument-splattering. Essentially flattens an array inline, as if the elements of an array had been included individually. It works both ways. Very useful, and some patterns with iterators rely on it. Here are some contrived examples:
x = [1, 2]
puts [0, x, 3].inspect
puts [0, *x, 3].inspect
def first_and_last f, *_, l; [f, l]; end
puts first_and_last(1, 2, 3, 4, 5).inspect