Skip to content

math.fractions: use operator overloading and deprecate old functions - #19547

Merged
medvednikov merged 2 commits into
vlang:masterfrom
Delta456:use_operload_overloading_fractions
Oct 11, 2023
Merged

medvednikov merged 2 commits into
vlang:masterfrom
Delta456:use_operload_overloading_fractions

Conversation

@Delta456

@Delta456 Delta456 commented Oct 10, 2023 •

Copy link
Copy Markdown
Member

πŸ€– Generated by Copilot at 7737f70

Improved the Fraction type in the math/fractions module by using standard operators for equality and comparison, and making the reduce method return a new value instead of modifying the original one. This makes the Fraction type more consistent and easier to use.

πŸ€– Generated by Copilot at 7737f70

  • Deprecated equals, lt, le, gt, and ge methods of the Fraction struct and replaced them with ==, <, <=, >, and >= operators, respectively, to make the code more idiomatic and consistent with other types in V. (link, link, link, link, )
  • Updated the test cases in fraction_test.v to use the new operators instead of the deprecated methods. (link, link, link, link, link, link, link, link, link, link)
  • Changed the reduce method of the Fraction struct to return a new Fraction instead of modifying the original one, to make it more pure and functional. ( link)

@medvednikov
medvednikov merged commit 491b5f7 into vlang:master Oct 11, 2023
@Delta456
Delta456 deleted the use_operload_overloading_fractions branch October 11, 2023 05:23
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.

3 participants