Scala - View Bound Last Updated : 03 Jul, 2020 Comments Improve Suggest changes Like Article Like Report Type Bounds in Scala are restrictions on type parameter or type variable. By the usage of these type bounds, we can set up limits for the variables. These bounds help to put up our code into real-world examples. We need to impose certain limitations and boundaries to every factor in real life, that is what the Type bounds do in Scala. There are three types of types bounds supported in Scala: Upper Bound Lower Bound View Bound Here we will discuss view bound. View Bound is one of the type bound used in Scala. View bound is basically used where existing implicit conversions are used automatically. In some programs, to solve any problem implicit conversions are done automatically. View bound is used to take advantage of these implicit conversions. Syntax: [T <% S] Here, T is a type parameter and S is a type. <% denotes view bound. Below examples illustrate the concept of view bound in Scala: Example 1: Scala // Scala program to demonstrate view bound // Declaration of view bound class GFG[T <% Ordered[T]](val firstNumber: T, val secondNumber: T) { def greaterNumber = if (firstNumber > secondNumber)firstNumber else secondNumber } // Object created object ViewBoundExample { // Driver code def main(args: Array[String]) { val result = new GFG(24, 25) println(result.greaterNumber) } } Output: 25 Example 2: Scala // Scala program to demonstrate view bound // Declaration of view bound class GFG[T <% Ordered[T]](val first_Str: T, val second_Str: T) { def smaller_Str = if (first_Str < second_Str)first_Str else second_Str } // Object created object ScalaViewBound { // Driver code def main(args: Array[String]) { val result = new GFG("GeeksforGeeks", "Scala") println(result.smaller_Str) } } Output: GeeksforGeeks Comment More infoAdvertise with us Next Article Scala - View Bound P pp_pankaj Follow Improve Article Tags : Scala Scala-Basics Similar Reads Scala | Upper bound Scala has some restrictions on the Type Parameters or Type Variable i.e, (type bound) and Upper bound is one of them. By implementing Type Bounds, We can explicate the restraints of a Type Variable, these type bound restricts the definite values of the type variables and discloses more details about 2 min read Scala | Lower Bound Type Bound basically is a kind of restriction on the parameter or the variable. By the usage of these type bounds we can set up limits for the variables. These bounds help to put up our code into real world examples. We need to impose certain limitations and boundaries to every factor in real life, 4 min read Scala Context Bound Context bound is a shorthand for expressing the common pattern of a context parameter that depends on a type parameter. Type parameters are placeholders for types, these are used to write type generic code, and these are declared in []. Context parameters are implicit type parameters, they help enri 4 min read Scala Long <=(x: Byte) method In Scala, Long is a 64-bit signed integer, which is equivalent to Java's long primitive type. The <(x: Byte) method is utilized to return true if this value is less than or equal to x, false otherwise. Method Definition - def <=(x: Byte): Boolean Returns - Returns true if this value is less th 1 min read Scala Long >=(x: Byte) method In Scala, Long is a 64-bit signed integer, which is equivalent to Java's long primitive type. The >=(x: Byte) method is utilized to return true if this value is greater than or equal to x, false otherwise. Method Definition - def >=(x: Byte): Boolean Returns - Returns true if this value is gre 1 min read Like