Scala | Uniform Access Principle Last Updated : 08 Apr, 2019 Comments Improve Suggest changes Like Article Like Report In Scala, a programming abstraction is implemented which is called as Uniform Access Principle, which states that the annotations utilized to retrieve a property of a Class is equivalent for both methods and variables. This principle was imposed forward by Bertrand Meyer. The principle simply means that the notation used to access a feature of a class shouldn’t differ depending on whether it’s a method or an attribute . Some points to note: Using this Principle attributes and functions with no parameters can be accessed by identical syntax. The definition of a function with no parameters can be transformed to "var" or vice-versa. This Principle is more aligned to the object oriented programming. Example : Scala // Scala program for Uniform // Access Principle // Creating object object Access { // Main method def main(args: Array[String]) { // Creating array val x : Array[Int] = Array(7, 8, 9, 10, 45) // Creating String val y = "GeeksforGeeks" // Accessing length of an // array println(x.length) // Accessing length of a // String println(y.length) } } Output: 5 13 Now, We know that the length of an array is a variable and length of a string is a method in the Class "String" but we accessed both of them in same way. Example : Scala // Scala program for Uniform // Access Principle // Creating object object Access { // Main method def main(args: Array[String]) { // Creating a list val x = List(1, 3, 5, 7, 9, 10) // Creating a method def portal = { "Geeks" +"for" + "Geeks" } // Accessing size of a // method println(portal.size) // Accessing size of a // variable println(x.size) } } Output: 13 6 Here, also a variable and a method both are accessed in a same manner. Comment More infoAdvertise with us Next Article Scala | Uniform Access Principle N nidhi1352singh Follow Improve Article Tags : Scala Scala Scala-Basics Similar Reads How to check if a file exists in Scala? When working on software projects it's crucial to check if a file exists before you interact with it in any way such as reading, writing, or modifying it. This practice helps avoid issues that may arise from attempting to handle an existing file. Scala provides methods to perform this check for the 2 min read Call a method on a Super Class in Scala This concept is used when we want to call super class method. So whenever a base and subclass have same named methods then to resolve ambiguity we use super keyword to call base class method. The keyword "super" came into this with the concept of Inheritance. Below is the example of call a method on 2 min read Scala | Methods to Call Option The Option in Scala is referred to a carrier of single or no element for a stated type. When a method returns a value which can even be null then Option is utilized i.e, the method defined returns an instance of an Option, in place of returning a single object or a null. There are a few methods that 5 min read Abstract Classes in Scala Abstraction is the process to hide the internal details and showing only the functionality. In Scala, abstraction is achieved by using an abstract class. The working of the Scala abstract class is similar to Java abstract class. In Scala, an abstract class is constructed using the abstract keyword. 5 min read Scala | Value Classes Value classes are a new mechanism which help to avoid allocating run time objects. AnyVal define value classes. Value classes are predefined, they coincide to the primitive kind of Java-like languages. There are nine predefined value types : Double, Float, Long, Int, Short, Byte, Char, Unit, and Boo 2 min read Like