Heighten and Widen are the functions needed to enable the clients to place elements of different widths on top of each other, or place elements of different heights beside each other. These functions takes a width or a height and returns an element having the same width or height respectively.
For example, evaluating the following expression would not work correctly, because the second line in the combined element is longer than the first:
new ArrayElement(Array("geeks")) above new ArrayElement(Array("forgeeks"))
Similarly, evaluating the following expression would not work properly too, because the first ArrayElement has a height of two, and the second a height of only one:
new ArrayElement(Array("yes", "no")) beside new ArrayElement(Array("yes"))
The code fragment below contains a private function widen, which takes a width and returns an Element of that width. The result contains the contents of this Element centered padded to the left and right by any spaces needed to achieve the required width. Similarly, it contains another private function heighten, which performs the same function in the vertical direction. The widen method is invoked by above to ensure that Elements placed above each other have the same width. Similarly, the heighten method is invoked by beside to ensure that elements placed beside each other have the same height.
- Scala Tutorial – Learn Scala with Step By Step Guide
- Scala | Either
- Scala Map
- Set in Scala | Set-2
- Set in Scala | Set-1
- Recursion in Scala
- Scala Int >>>(x: Int) method with example
- while and do while Loop in Scala
- StringBuilder in Scala
- Scala Int >=(x: Int) method with example
- Scala Int >>(x: Int) method with example
- Scala Stream
- Scala Int <<(x: Int) method with example
- Scala | Annotation
- Scala | Multithreading
- Scala Byte +(x: Int): Int
- Scala | Ranges
- How to get all the values from a Scala map
- How to get all the keys from a Scala map
- Scala Int >(x: Int) method with example
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.