I'm trying to retain the selected value of a dropdownlist once the user change the dropdownlist item but its not working as expected what I wanted is to retain the selected item in the dropdownlist but its it defaulted to the `Select Company` everytime i select the item from dropdownlist, once the user change it postback the page (i know there is no postback in the MVC)

What I'm doing wrong here?

```
<div class="form-group">
   @using (Html.BeginForm("Index", "Home", FormMethod.Post, new { @id = "form_dropdown" }))
   {
      @Html.DropDownListFor(m => m.ListOfCompanies, 
      new SelectList((System.Collections.IEnumerable)Model.ListOfCompanies, "Value", "Text"), 
      "Select Company", new { @class = "form-control", Name = "sel" })
  } 

```

```
[HttpPost]
public ActionResult Index(string sel)
{
   var vModel = new EmployeeViewModel();
   vModel = _db.GetEmployee.ToList();

   //load list of companies:

   var company =   _db.LoadComapny.ToList();          
   IEnumerable<SelectListItem> result = model.Select(b => new SelectListItem
   {
       Value = b.Value,
       Text = b.Text,
       Selected = b.Text == sel
   }).ToList(); 

   vModel.ListOfCompanies = company;
   vModel.SELECTED_COMPANY = sel;

   return View(vModel);
}

```

Model:

```
public class EmployeeViewModel
{
   public IEnumerable<SelectListItem> ListOfCompanies { get; set; }
   public string SELECTED_COMPANY { get; set; }
   //other props
}

```
['https://Stackoverflow.com/questions/31441040', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/275390/']
As I wrote in the comment section, it's really unclear to me what you're asking.
However, looking at your code examples, it seems to me that `trait A` isn't really required.
You can use the types that already come with the Scala SDK:

```
object B extends (()=>Unit) {
  def apply() { /* implementation */ }
}

```

Or, as a variant:

```
object B {
  val aType:()=>Unit = {() => /* implementation */ }
}

```

In the first case, you can access the singleton instance with `B`, in the second case with `B.aType`.
In the second case, no explicit declaration of the `apply` method is needed.

Pick what you like.
The essential message is: You don't need a trait if you just define one simple method.
That's what Scala functions are for.

The list type might look like this:

```
private val aList:ListBuffer[()=>Unit] = ???

```

(By the way: Why not declare it as `Seq[()=>Unit]`? Is it important to the caller that it is a `ListBuffer` and not some other kind of sequence?)

Your worker might then look like this:

```
abstract class Worker {
  def aType:()=>Unit // no need for the `get` prefix here, or the empty parameter list
  def do() {aType()}
}

```

Note that now the `Worker` type has become a class that offers a method that invokes a function.
So, there is really no need to have a `Worker` class.
You can just take the function (`aType`) directly and invoke it, just so.

If you always want to call the implementation in `object B`, well - just do that then.
There is no need to wrap the call in instances of other types.
Your example class `B` just forwards the call to the `B` object, which is really unnecessary.
There is no need to even create an instance of `B`.
It does have the private member variable `creator`, but since it's never used, it will never be accessed in any way.

So, I would recommend to completely remove the `class B`.
All you need is the type `()=>Unit`, which is exactly what you need: A function that takes no parameters and returns nothing.

If you get tired of writing `()=>Unit` all the time, you can define a type alias, for example inside the package object.
Here is my recommentation:

```
type SideEffect = ()=>Unit

```

Then you can use `SideEffect` as an alias for `()=>Unit`.

That's all I can make of it.
It looks to me that this is probably not what you were looking for.
But maybe this will help you a little bit along the way.
If you want to have a more concrete answer, it would be nice if you would clarify the question.
The notion of a *companion object* extending a trait is useful for defining behavior associated with the class itself (e.g. static methods) as opposed to instances of the class. In other words, it allows your static methods to implement interfaces. Here's an example:

```
import java.nio.ByteBuffer

// a trait to be implemented by the companion object of a class
// to convey the fixed size of any instance of that class
trait Sized { def size: Int }

// create a buffer based on the size information provided by the
// companion object
def createBuffer(sized: Sized): ByteBuffer = ByteBuffer.allocate(sized.size)

class MyClass(x: Long) {
  def writeTo(buffer: ByteBuffer) { buffer.putLong(x) }
}
object MyClass extends Sized {
  def size = java.lang.Long.SIZE / java.lang.Byte.SIZE
}

// create a buffer with correct sizing for MyClass whose companion
// object implements Sized. Note that we don't need an instance
// of MyClass to obtain sizing information.
val buf = createBuffer(MyClass)

// write an instance of MyClass to the buffer.
val c = new MyClass(42)
c.writeTo(buf)

```