<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Interfaces on F# for Fun and Profit</title>
    <link>https://fsharpforfunandprofit.com/categories/interfaces/</link>
    <description>Recent content in Interfaces on F# for Fun and Profit</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en-us</language>
    <lastBuildDate>Tue, 17 Jul 2012 00:00:00 +0000</lastBuildDate><atom:link href="https://fsharpforfunandprofit.com/categories/interfaces/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Object expressions</title>
      <link>https://fsharpforfunandprofit.com/posts/object-expressions/</link>
      <pubDate>Tue, 17 Jul 2012 00:00:00 +0000</pubDate>
      
      <guid>https://fsharpforfunandprofit.com/posts/object-expressions/</guid>
      <description>So as we saw in the previous post, implementing interfaces in F# is a bit more awkward than in C#. But F# has a trick up its sleeve, called &amp;ldquo;object expressions&amp;rdquo;.
With object expressions, you can implement an interface on-the-fly, without having to create a class.
Implementing interfaces with object expressions     Object expressions are most commonly used to implement interfaces. To do this, you use the syntax new MyInterface with .</description>
    </item>
    
    <item>
      <title>Interfaces</title>
      <link>https://fsharpforfunandprofit.com/posts/interfaces/</link>
      <pubDate>Mon, 16 Jul 2012 00:00:00 +0000</pubDate>
      
      <guid>https://fsharpforfunandprofit.com/posts/interfaces/</guid>
      <description>Interfaces are available and fully supported in F#, but there are number of important ways in which their usage differs from what you might be used to in C#.
Defining interfaces     Defining an interface is similar to defining an abstract class. So similar, in fact, that you might easily get them confused.
Here&amp;rsquo;s an interface definition:
type MyInterface = // abstract method  abstract member Add: int -&amp;gt; int -&amp;gt; int // abstract immutable property  abstract member Pi : float // abstract read/write property  abstract member Area : float with get,set And here&amp;rsquo;s the definition for the equivalent abstract base class:</description>
    </item>
    
  </channel>
</rss>
