Scala equivalent of C#’s extension methods?

前端 未结 5 1773
傲寒
傲寒 2020-12-07 12:09

In C# you can write:

using System.Numerics;
namespace ExtensionTest {
public static class MyExtensions {
    public static BigInteger Square(this BigInteger          


        
5条回答
  •  温柔的废话
    2020-12-07 12:35

    In Scala we use the so-called (by the inventor of the language) Pimp My Library pattern, which is much discussed and pretty easy to find on the Web, if you use a string (not keyword) search.

提交回复
热议问题