justinian/dice

embedded fmt.Stringer

Closed this issue · 1 comments

This isn't necessarily an issue so much as an attempt at understanding the code, but why is the RollResult interface defined with the embedded interface fmt.Stringer. As far as I know this is functionally equivalent to String() string in the interface definition, yes?

Anyway, thanks for the library more generally, I was sitting down thinking of some ideas for CLI helper tools for running some RPGs and realized that a first start was a parser/roller for '3d6' style strings, but figured I better check to make sure someone else hadn't done it first before potentially replicating a lot of work!

Yeah, exactly - both are equivalent. The original version of the code just returned fmt.Stringer, which is probably one reason I leaned towards using the embedded interface. Also, I just like composition of existing things instead of repeating them.

Glad you found it useful! Feel free to send PRs if there's anything you want to add.