Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • DSA
  • Practice Problems
  • Python
  • C
  • C++
  • Java
  • Courses
  • Machine Learning
  • DevOps
  • Web Development
  • System Design
  • Aptitude
  • Projects
Open In App
Next Article:
Scala List :::() operator with example
Next article icon

Scala List +() operator with example

Last Updated : 26 Jul, 2019
Comments
Improve
Suggest changes
Like Article
Like
Report
The +() operator in Scala is utilized to append an element to the list.
Method Definition: def +(elem: A): List[A] Return Type: It returns a list of the stated elements after appending it to an another element.
Example #1: Scala
// Scala program of +() // method  // Creating object object GfG {       // Main method     def main(args:Array[String])     {              // Creating a list         val m1 = List(1, 2, 3)                  // Applying + operator         val res = m1.+("10")                  // Displays output         println(res)          } } 
Output:
  List(1, 2, 3)10  
Example #2: Scala
// Scala program of +() // method  // Creating object object GfG {       // Main method     def main(args:Array[String])     {              // Creating a list         val m1 = List()                  // Applying + operator         val res = m1.+("10")                  // Displays output         println(res)          } } 
Output:
  List()10  

Next Article
Scala List :::() operator with example
author
nidhi1352singh
Improve
Article Tags :
  • Scala
  • Scala
  • Scala-Method
  • Scala-list

Similar Reads

  • Scala List :::() operator with example
    The :::() operator in Scala is utilized to join the List in the argument to the another List. Method Definition: def :::(prefix: List[A]): List[A] Return Type: It returns a list after joining one list to the another one. Example #1: // Scala program of :::() // method // Creating object object GfG {
    1 min read
  • Scala List ::() operator with example
    The ::() operator in Scala is utilized to add an element to the beginning of the List. Method Definition: def ::(x: A): List[A] Return Type: It returns the stated list after adding an element to the beginning of it. Example #1: // Scala program of ::() // method // Creating object object GfG { // Ma
    1 min read
  • Scala List map() method with example
    The map() method is utilized to apply the stated function to all the elements of the list. Method Definition: def map[B](f: (A) => B): List[B] Return Type: It returns a new list after applying the stated function to all the elements of the list. Example #1: // Scala program of map() // method //
    1 min read
  • Scala List sum() method with example
    The sum() method is utilized to add all the elements of the stated list. Method Definition: def sum(num: math.Numeric[B]): B Return Type: It returns the sum of all the elements of the list. Example #1: // Scala program of sum() // method // Creating object object GfG { // Main method def main(args:A
    1 min read
  • Scala List apply() method with example
    The apply() method is utilized to select an element in the list by its index. Method Definition: def apply(n: Int): A Return Type: It returns an element from the given list by its index which is present in the apply method as argument. Example #1: // Scala program of apply() // method // Creating ob
    1 min read
  • Scala ListSet sum() method with example
    In Scala ListSet, sum() method is utilized to add all the elements of the stated listSet. Method Definition: def sum(num: math.Numeric[B]): B Return Type: It returns the sum of all the elements of the listSet. Example 1: C/C++ Code // Scala program of sum() // method import scala.collection.immutabl
    1 min read
  • Scala Iterator sum() method with example
    The sum() method belongs to the concrete value members of the class AbstractIterator. It is defined in the classes TraversableOnce and GenTraversableOnce. It adds the elements of the stated collection. Method Definition: def sum: A Return Type: It returns the sum of all the elements in the stated it
    1 min read
  • Scala Iterator map() method with example
    The map() method belongs to the concrete value member of the class Abstract Iterator. It is utilized to build a new iterator by applying a function to each of the elements of the stated iterator. Method Definition: def map[B](f: (A) => B): Iterator[B] where, B is the element type of the returned
    2 min read
  • Scala Map iterator method with example
    The iterator method is utilized to give an iterator. Method Definition: def iterator: Iterator[(A, B)] Return Type: It returns a non-empty iterator for non-empty map and returns an empty iterator for empty map. Example #1: // Scala program of iterator // method // Creating object object GfG { // Mai
    1 min read
  • Scala Iterator forall() method with example
    The forall() method belongs to the concrete value members of the Class AbstractIterator. It is defined in the class IterableOnceOps. It tests whether a used predicate holds for all the elements of the stated collection. It may not terminate for the infinite sized collection. Method Definition : def
    1 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences