Examples

Page 34 of 50

Browse code examples

javaSnippet

BigDecimal Scale And Rounding

Do money math with BigDecimal instead of double: explicit setScale with RoundingMode, and compareTo instead of equals because scale makes 2.50 differ from 2.5.

rustSnippet

Arrays Versus Vec Fixed Sizes

Fixed-size arrays carry their length in the type, so a signature can force wrong lengths out at compile time, while Vec grows and both borrow as one slice.