In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces "what is the Scala view". In the daily operation, I believe that many people have doubts about what the Scala view is. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful for you to answer the doubts about "what is the Scala view?" Next, please follow the editor to study!
View
Implicit parameters and methods can also define implicit conversions, called views. The view from type S to type T is defined by an implied value of function type S = > T or (= > S) = > T or a value that can be converted to that type.
Views are applied in two cases.
1. If the expression e type is T and T is inconsistent with the expected type of the expression. In this case, there will be a search for an implied vjournal v that can be applied to e and the result type is the same as pt. The form of the search is similar to the implicit parameter, and the implicit scope is similar to T = > pt. If such a view is found, the expression e becomes v (e).
two。 Select e.m, e is of type T, if selector m does not represent a member of T. In this case, the search view vjournal v can be applied to e and the result contains a member named m. The form of the search is similar to the implied parameter, and the implicit scope is T. If such a view is found, select e.m to change to v (e) .m.
For implicit parameters, if there is more than one option, overload parsing is applied.
Example 7.3.1 Class scala.Ordered [A] has a method
Def: a] (that: B) (implicit b2ordered: B = > Ordered [B]): Boolean
There are two lists xs and ys of type List [Int], and the methods list2ordered and int2ordered defined in §7.2 are in scope, so the operation
Xs
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.