Skip to content

Commit

Permalink
Update fun-interfaces.md
Browse files Browse the repository at this point in the history
SAM can have only one abstract method. But it is written wrong on this page. I modified that.
  • Loading branch information
sdboyapati authored and sarahhaggarty committed Aug 29, 2024
1 parent cc107db commit b00175e
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions docs/topics/fun-interfaces.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
[//]: # (title: Functional \(SAM\) interfaces)

An interface with only one abstract method is called a _functional interface_, or a _Single Abstract
Method (SAM) interface_. The functional interface can have several non-abstract members but only one abstract member.
An interface with only one abstract member function is called a _functional interface_, or a _Single Abstract
Method (SAM) interface_. The functional interface can have several non-abstract member functions but only one abstract
member function.

To declare a functional interface in Kotlin, use the `fun` modifier.

Expand Down Expand Up @@ -117,7 +118,7 @@ However, functional interfaces and [type aliases](type-aliases.md) serve differe
Type aliases are just names for existing types – they don't create a new type, while functional interfaces do.
You can provide extensions that are specific to a particular functional interface to be inapplicable for plain functions or their type aliases.

Type aliases can have only one member, while functional interfaces can have multiple non-abstract members and one abstract member.
Type aliases can have only one member, while functional interfaces can have multiple non-abstract member functions and one abstract member function.
Functional interfaces can also implement and extend other interfaces.

Functional interfaces are more flexible and provide more capabilities than type aliases, but they can be more costly both syntactically and at runtime because they can require conversions to a specific interface.
Expand Down

0 comments on commit b00175e

Please sign in to comment.