Skip to content

Commit

Permalink
fix: remove Append from Data (make it optional)
Browse files Browse the repository at this point in the history
  • Loading branch information
maaslalani committed Oct 5, 2023
1 parent e26eec2 commit f184359
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
6 changes: 0 additions & 6 deletions table/rows.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package table
// Data is the interface that wraps the basic methods of a table model.
type Data interface {
Row(row int) Row
Append(row Row)
Count() int
Columns() int
}
Expand Down Expand Up @@ -110,11 +109,6 @@ func (m *Filter) Row(row int) Row {
return nil
}

// Append appends the given row to the table.
func (m *Filter) Append(row Row) {
m.data.Append(row)
}

// Columns returns the number of columns in the table.
func (m *Filter) Columns() int {
return m.data.Columns()
Expand Down
10 changes: 8 additions & 2 deletions table/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,10 @@ func (t *Table) Rows(rows ...[]string) *Table {
t.data = NewStringData()
}
for _, row := range rows {
t.data.Append(StringRow(row))
switch t.data.(type) {
case *StringData:
t.data.(*StringData).Append(StringRow(row))
}
}
return t
}
Expand All @@ -125,7 +128,10 @@ func (t *Table) Row(row ...string) *Table {
if t.data == nil {
t.data = NewStringData()
}
t.data.Append(StringRow(row))
switch t.data.(type) {
case *StringData:
t.data.(*StringData).Append(StringRow(row))
}
return t
}

Expand Down

0 comments on commit f184359

Please sign in to comment.